#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int p[n];
    for(int i = 0; i < n; i++)
        cin >> p[i];

    if(k == p[n-1])
        cout << p[0];
    else
    {
        int m = 0;
        for(int i = 0; i < n; i++)
        {
            if(k == p[i])
            {
                m = i;
                break;
            }
        }
        cout << p[m+1];
    }
    return 0;
}