#include <bits/stdc++.h>
using namespace std;
int t, arr[100009], n, m, k;
int main() {
cin >> n >> k;

for (int i = 1; i <= n; i++) {
    cin >> arr[i];
}

for (int i = 1; i <= n; i++) {
    if (arr[i] == k) {
        cout << arr[i+1] << "\n";
        return 0;
    } else if (arr[n] == k) {
        cout << arr[1] << "\n";
        return 0;
    }
}

return 0;
}