#include <bits/stdc++.h>
using namespace std;
int n,k,br;
int niz[20005];
int main(){
cin>>n>>k;
    for(int i=1;i<=n;i++){
    cin>>niz[i];
        if(niz[i]==k){
          br=i;
        }
    }
    if(niz[n]==k){
        cout<<niz[1]<<endl;
    }
        else cout<<niz[br+1]<<endl;
return 0;
}