#include <iostream>

using namespace std;

int main()
{
    int N, K, i;
    
    cin>>N>>K;
    
    int p[N];
    
    for(int j = 0; j < N; j++)
    {
        cin>>p[j];
        
        if(p[j] == K)
            i = j;
    }
    
    if(N == i + 1)
        cout<<p[0];
    else
        cout<<p[i+1];
    
    return 0;
}