#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int niz[n];
    int ind;
    for(int i = 0; i < n; i++)
    {
        cin >> niz[i];
        if (niz[i] == k)
        {
            ind = i;
        }
    }
    if(ind + 1 == n)
    {
        cout << niz[0];
    }
    else
        cout << niz[ind + 1];
    return 0;
}