#include <iostream>
using namespace std;

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