#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	int k; cin >> k;
	int ans;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
		if(p[i]==k){
			ans = (i+n-1)%n;
		}
	}
	cout << p[ans] << '\n';
	return 0;
}