#include <iostream>

using namespace std;

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