#include <iostream>

using namespace std;

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