#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define endl "\n"

using namespace std;

void solve()
{
    int n,k; cin >> n >> k;

    vector<int> v(n);
    for(int& x:v) cin >> x;

    for(int i=0; i<n; i++) {
        if(v[i] == k) {
            cout << (i==n-1 ? v[0] : v[i+1]) << endl;
            return;
        }
    }
}

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

    int t=1; //cin >> t;

    while(t--)
        solve();

    return 0;
}