#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k, i1;
    
    cin >> n >> k;
    vector <int> a(n);
    
    for(int i = 0;i < n;i ++)
    {
        cin >> a[i];
    }
    

    if(k!=a[n-1])
    {
        for(int i = 0;i < n;i ++)
        {
            if(k == a[i])
            {
                i1 = i;
                break;
            }
        }
        cout << a[i1+1] << endl;
    }
    else
    {
       cout << a[0] << endl; 
    }
    
    return 0;
}