#include <iostream>
//#include <fstream>
//#include <iomanip>
//#include <cmath>
//#include <algorithm>
//#include <string>
//#include <vector>
//#include <utility>
//#include <map>
//#include <ctime>
//#include <cctype>
//#include <cstdlib>
//#include <limits>
//#include <numeric>
//#include <mycpp.h>

using namespace std;

int main()
{
	std::ios_base::sync_with_stdio(false);
	int n, k, ind = 0;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		if(a[i] == k) ind = i;
	}
	cout << a[(ind + 1) % n];
}