#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, k, ind = 0;

    cin >> n >> k;

    int a[n];

    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] == k) ind = i;
    }

    if(ind == n-1) cout << a[0];
    else cout << a[ind+1] << '\n';
    return 0;
}