#include<bits\stdc++.h>

using namespace std;

int main()
{
	int n, k, p[20000], j = 0;
	
	cin >> n >> k;
	
	for(int i = 0; i < n; i++)
	{
		cin >> p[i];
		if(p[i] == k) j = i;
	}
	
	if(j == n - 1) j = -1;
	
	cout << p[j + 1];
}