#include<bits/stdc++.h>
using namespace std;

#define ll long long


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	map<int, int> poj;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		poj[a[i]] = i;
	}

	if (poj[k] == n - 1) {
		cout << a[0] << "\n";
	}
	else {
		cout << a[poj[k] + 1] << "\n";
	}

	return 0;
}