#include <iostream>
using namespace std;

int main(){
    int i, n, k;
    cin >> n >> k;
    int p[n];
    for(i = 0; i < n; i++)
        cin >> p[i];

    int pk;
    for(i = 0; i < n; i++)
        if(p[i] == k){
            pk = i;
            break;
        }

    cout << ( (pk != n - 1) ? p[pk + 1] : p[0] ) << endl;
    return 0;
}