#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<ll> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (arr[i] == k)
		{
			if (i == n-1) {
				cout << arr[0] << "\n";
			}
			else {
				cout << arr[i+1] << "\n";
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}