#include <iostream>


using namespace std;
int main() {
	int n, k;
	int p[20004];
	cin>>n>>k;
	for(int i = 0;i<n;i++){
		cin>>p[i];
	}
	int p_index = -1;
	for(int i = 0;i<n;i++){
		if(p[i] == k){
			p_index = i;
			break;
		}
	}
	if(p_index<n-1){
		cout<<p[p_index+1];
	}else cout<<p[0];
	return 0;
}