#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,k,p[20005];
int r;
int main () {
    cin>>n>>k;
    for (int i=1;i<=n;i++) {
        cin>>p[i];
        if (k==p[n]) {r=p[1];}
    }
    for (int i=1;i<=n;i++) {
        if (k!=p[n] and k==p[i]){
            r=p[i+1];
        }
    }
    cout<<r;
    return 0;
}