#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
#define pb push_back
#define PI 3.14159265
#define pii pair<int,int>
//#define f first
//#define s second
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int a[20000];
 
int main()
{
	//fasti
	int n,k,j;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		if(a[i]==k) j=i;
	}
	//cout<<j<<"\n";
	if(j<n-1) cout<<a[j+1];
	else cout<<a[0];
	
	
	
}