#include <iostream>

using namespace std;

const int max_n=20000;
const int min_n=2;

int main()
{
    int n, k, i;
    cin >> n >> k;
    int *a=new int(n);
    for (i=0; i<n; i++)
        cin >> a[i];
    int rez, tmp;
    for (i=0; i<n; i++)
        if(a[i]==k)
        {
            tmp=i;
            break;
        }
    if(tmp==n-1)
        rez=a[0];
    else
        rez=a[tmp+1];
    cout << rez;
    return 0;
}