#include <iostream>
#define ll long long

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	int i;
	int j;
	int* nums = new int[n];
	for (i = 0; i < n; i++) {
		cin >> nums[i];
		if (nums[i] == k)
			j = i;
	}
	cout << nums[(j + 1) % n];
	return EXIT_SUCCESS;
}