#include <iostream>
using namespace std;

int main() {
	unsigned short int i,N,K;
	cin>>N;
	cin>>K;
	unsigned short int p[N];
	for(i=0;i<N;i++){
		cin>>p[i];
	}
	if(K==p[N-1]){
		cout<<p[0];
	}
	else{
		for(i=0;i<N;i++)
			{
				if(p[i]==K)
					break;
			}
		cout<<p[i+1];
	}
	return 0;
}