#include <bits/stdc++.h>
#define en '\n'
#define fi first
#define se second
#define pii pair<int,int>

using namespace std;

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

    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    int ind = 0;
    for(int i = 0; i < n ; i++)
    {
        cin >> p[i];
        if(p[i]==k) ind=i;
    }
    if(ind == n - 1) cout << p[0] << en;
    else cout << p[ind+1] << en;
    return 0;
}