#include<iostream>
using namespace std;
const int nmax=2e4+1;
int n,ar[nmax],k,ans,ansi;
int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> ar[i];
		if(ar[i]==k)ansi=i;	
	}
	if(ansi>=n-1)ansi=-1;
	cout << ar[ansi+1];
}