#include <bits/stdc++.h>

using namespace std;

int main()
{
int n, k;
cin >> n >> k;
int a[n];
int index;
for (int i = 0; i < n; i++)
{
	cin >>	a[i];
	if(a[i]==k)
	index = i;
}
if(index == n-1)
cout<<a[0];
else cout << a[index+1];
return 0;
}