#include <bits/stdc++.h>
using namespace std;

int n,k,p[20005];

int main(){
    cin >> n >> k;

    for(int i = 1; i <= n; i++){
      cin >> p[i];
    }

    for(int i = 1; i <= n; i++){
      if(p[n] == k){
        cout << p[1] << endl;
        break;
      }
      else if(p[i] == k){
        cout << p[i+1] << endl;
      }
    }

    return 0;
}