#include <bits/stdc++.h>

using namespace std;

int getIndex(vector<int> v, int K)
{
    auto it = find(v.begin(), v.end(), K);

    if (it != v.end())
    {
        int index = it - v.begin();
        return index;
    }
}
int main()
{
    int n; cin >> n;
    int k; cin >> k;
    vector<int> v;

    for(int i = 0; i < n; i ++)
    {
        int a; cin >> a;
        v.push_back(a);
    }
    
    if(k == v[n-1])
    {
        cout << v[0] << endl;
    }
    else
    {
        int indeks = getIndex(v, k) + 1;
        cout << v[indeks] << endl;
    }
    return 0;
}