#include <iostream>

using namespace std;

int main(){
	int N, K, s;
	cin >> N >> K;
	
	int a[N];
	for (int i = 0; i < N; i++){
		cin >> a[i];
		if (a[i] == K){
			s = i;
		}
	}
	
	s++;
	if (s == N){
		s = 0;
	}
	
	cout << a[s] << endl;
}