#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int n, k, i=0, m;
	cin>>n>>k;
	int niz[n];
	while(i<n)
	{
		cin>>niz[i];
		if(niz[i]==k)m=i;
		i++;
	}
	if(m==n-1)return cout<<niz[0],0;
	else return cout<<niz[m+1],0;
	return 0;
}