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

int main(int argc, char const *argv[])
{
	int n, k, t;
	cin >> n >> k;
	vector<int> vec(n);
	int j;
	for (int i = 0; i < n; i++) {
		cin >> t;
		vec[i] = t;
		if (t == k)
			j = i;
	}
	if (j == n - 1) {
		cout << vec[0] << endl;
	}
	else {
		cout << vec[j + 1] << endl;
	}

	return 0;
}