#include <iostream>

using namespace std;

int main()
{
    int n,k,i,j;
    cin >> n >> k;
    int c[n];
    for (i=0;i<n;i++)
    {
        cin >> c[i];
        if (c[i]==k)
        {
            j=i;
        }
    }
    cout << c[(j+1)%n];
    return 0;
}