#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 200001;
const int inf = 1e9 + 7;
int a[N], b[N];

void solve() {
    int n, x, y, z;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ind = 0;
    for (int i = 0; i < n; i++)
        if (a[i] == x)
            ind = i;
    if (ind == n - 1) {
        cout << a[0] << endl;
    }
    else {
        cout << a[ind + 1] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}