#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cerr.tie(0);
    cout.tie(0);
    int k, n, lok;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == k)
            lok = i;
    }
    if (lok == n - 1)
        cout << a[0] << endl;
    else
        cout << a[lok + 1] << endl;
    return 0;
}