#include <bits/stdc++.h>

using namespace std;

int N, K, p[20005], kpoz;

int main () {
    cin >> N >> K;
    for (int i = 1; i <= N; i++){
         cin >> p[i];
         if (p[i] == K) kpoz = i;
    }

    if (kpoz == N) {
        cout << p[1];
    }
    else cout << p[kpoz+1];

return 0;
}