#include <iostream>

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    int karta[n], pos;

    for(int i = 0; i < n; i++){

        cin >> karta[i];

        if(k == karta[i]) pos = i;
    }
    if(pos == n-1) cout << karta[0];
    
    else cout << karta[pos+1];

    return 0;
}