#include <bits/stdc++.h>
#define MAXN 100010
#define pb push_back
#define ll long long
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

	int n, k, p[MAXN];
	cin >> n >> k;
	bool found = false;
	for (int i = 0; i < n; i++)
	{
        cin >> p[i];
        if (found == true)
        {
            cout << p[i];
            break;
        }
        if (p[i] == k && i != n-1)
            found = true;
        else if (p[i] == k && i == n-1)
            cout << p[0];
	}
	return 0;
}