#include <bits/stdc++.h>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll t, n, k, a[20005], pos[20005];

void solve(){
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  int ans;
  for(int i = 0; i < n; ++i){
    if(a[i] == k){ans = a[(i + 1) % n]; break;}
  }
  cout << ans << endl;

}

int main(){
  solve();
  return 0;
}