#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll long long
#define NMAX (int)1e6
#define vi vector<int>
#define pii pair<int,int>
#define w(x) cout<<#x<<':'<<x<<endl;
#define PB push_back
#define juseinbolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    juseinbolt;

    int n,k,ans; cin>>n>>k;
    int a[n];
    for(auto &x:a) cin>>x;
    for(int i=0; i<n; ++i)
    {
        if(k==a[i])
        {
            ans=a[(i+1)%n];
            break;
        }
    }
    cout<<ans;
    return 0;
}