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



return 0;
}