#include <stdio.h>
#include <stdlib.h>



int main() {
	
	int n;
	int k;
	
	scanf("%d %d", &n, &k);
	
	int red[n];
	
	int i = 0;;
	
	fflush(stdin);
	
	int checker = 0;
	
	do {
 
        scanf("%d", &red[i++]);
        
    } while (getchar() != '\n' && i < n);
	
	for(i = 0; i < n; i++){
		if(red[i] == k){
			checker = i;
			if(checker != n - 1){
			printf("%d", red[i + 1]);
		} else if(checker == n - 1){
			printf("%d", red[0]);
		}	
		
	}
	}
	
	return 0;
}