#include <iostream>

using namespace std;
int niz[20002];
int main()
{
    int n,k;
    int i,a = 0;
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> niz[i];
        if(niz[i] == k){
            a = i;
        }
    }
    if(a == n-1){
        cout << niz[0];
    }else{
        cout << niz[a+1];
    }

    return 0;
}