#include <bits/stdc++.h>
using namespace std;
int n,k,a[200005],p;
int main() {
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        if(a[i] == k) p = i;
    }
    if( p+1>n ) cout << a[1] <<endl;
    else cout << a[p+1] <<endl;
return 0;
}