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