#include <bits/stdc++.h>

using namespace std;

#define w <
#define ww <<
#define W <=
#define e >
#define ee >>
#define E >=

int n,k,A[20010],m;

int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1; i W n; i++)
    {
        scanf("%d",&A[i]);
        if(A[i]==k)
        {
            m = i;
        }
    }
    if(m==n)
    {
        printf("%d\n",A[1]);
    }
    else
    {
        printf("%d\n",A[m+1]);
    }
    return 0;
}