#include <bits/stdc++.h>
#define en '\n'
#define ll long long
#define sp " "

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector <int> p (N);
    int poz = -1;
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        if (p[i] == K)
            poz = i;
    }
    if (poz == N - 1)
        cout << p[0];
    else
        cout << p[poz + 1];
}