#include <bits/stdc++.h>

using namespace std;

const int MAX = 20000;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int n, k;
  cin>>n>>k;
  int a[MAX];
  int pos = -1;
  for(int i = 0 ; i < n ; i++) {
    cin>>a[i];
    if(a[i] == k) pos = i;
  }

  if(pos == n-1) cout<<a[0];
  else cout<<a[pos+1];

  return 0;
}