#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
vector<ll> v;
int main(){
    ll n,k,a;
    cin>>n>>k;
    ll br=0;
    for(int i=0;i<n;++i){
    	cin>>a;
    	v.pb(a);
    	if (a==k){
    		br=i;
		}
	}
	if(br==n-1){
		cout<<v[0];
		return 0;
		
	}
	cout<<v[br+1];
	return 0;
}