#include<iostream>

using namespace std;

void FICA()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n,k;

    cin>>n>>k;

    int niz[n],helper;

    for(int i=0;i<n;++i){
        cin>>niz[i];
        if(niz[i] == k)
            helper = i;
    }

    if(helper == n - 1){
        cout<<niz[0]<<endl;
    }else{
        cout<<niz[helper+1]<<endl;
    }
}

int main(void)
{
    FICA();
    return 0;
}