#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,k,p;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
        cin>>v[i];
        if(v[i]==k) p=i;
	}
    if(n==2){
        if(k==2)
            cout<<"1";
        else
            cout<<"2";
    }else{
        if(k==v[n-1])
            cout<<v[0];
        else
            cout<<v[p+1];
    }
	return 0;
}