#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
using namespace std;
long long a[200000005], t, n, k, b;
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] == k)b = i;
    }
    if (k != a[n]) {
        cout << a[b+1];
    }
    else if (k == a[n]) {
        cout << a[1];
    }
    return 0;
}