// I may fail a thousand times
// But there is no giving up
// IOI - here I come
#include <iostream>
using namespace std;
int a[(int)2e4+5];
int p[(int)2e4+5];
signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i],p[a[i]]=i;
	cout<<a[(p[k]+1)%n]<<'\n';
	return 0;
}