#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
	
	int n, k, i, a;
	
	scanf("%d%d", &n, &k);
	
	int n1[n];
	
	for(i = 0; i<n;i++){
		
		scanf("%d", &n1[i]);
		if(k == n1[n-1]){
			a = n1[0];
		}else if(k == n1[0]){
			 a = n1[n-1];
		} else if(k == n1[i] && i !=0){
			a = n1[i-1];
		}
		
	}
	
	printf("%d", a);
	
	return 0;

}