#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+45;
long long n,k,i,brojac,a[N];

int main()
{
	cin>>n>>k;
	for(i=1;i<=n;i++) 
	{
		cin>>a[i];
		if(a[i]==k) brojac=i;
	}
	if(brojac==n) cout<<a[1]<<endl;
	else cout<<a[brojac+1]<<endl;

}