#include <iostream>
using namespace std;
int main(){
int n,k;
cin>>n;
cin>>k;
int djole[n];
int i=0;
int resenje;
while(i<n){
cin>>djole[i];
if(djole[i]==k&&i!=n-1){cin>>djole[i+1];resenje=djole[i+1];break;break;}
else{if(djole[i]==k&&i==n-1){resenje=djole[0];break;break;}}
i++;
}
cout<<resenje;
return 0;
}