#include <bits/stdc++.h>
# define endl            '\n'
# define clr(x,a)        memset(x,a,sizeof(x))
# define vi              vector<int>
# define all(a)          a.begin(), a.end()
# define deb(x)          cout<<#x<<"=="<<x<<endl;
# define pb              push_back
# define sc              scanf
# define pr              printf
# define tc              int testcase; cin>>testcase; while(testcase--)
# define rev(s)          reverse(s.begin(),s.end())
# define linija          cout<<"___________\n";
using namespace std;
const int mxN=10005;
int n, k, a[20006], idx;
int main(){
   cin>>n>>k;
   for(int i=1; i<=n; i++){
      cin>>a[i];
      if(a[i]==k) idx=i;
   }
   if(idx==n) cout<<a[1]<<endl;
   else cout<<a[idx+1]<<endl;

   return 0;
}