#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mk make_pair
#define v_sort(x) sort(x.begin(),x.end())
#define v_gsort(x) sort(x.begin(),x.end(),greater<ll>())
#define v_find(x,num) find(x.begin(),x.end(),num)
#define PI 3.14159265
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18;

using namespace std;

void Solve(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  int idx=-1;
  for(int i=0;i<n;i++) {cin>>a[i];if(a[i]==k) idx=i;}
  if(idx==n-1) cout<<a[0]<<'\n';
  else cout<<a[idx+1]<<'\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t=1;
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
//  cin>>t;
  while(t--){
    Solve();
  }
  return 0;
}