#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
	int n,k,p[5],karta,mesanje1[]={},mesanje2[10],duzina=0,noviniz[5];
	cin >> n;
	p[n];
	cin >> k;
	for(int i = 1;i<=n;i++) {
		cin >> p[i];
	}
	duzina=sizeof(p)/sizeof(p[0]);
	for(int i=1;i<=n;i++) {
		if(p[i+1]<p[i]) {
		for(int j=0;j<sizeof(p)/sizeof(p[0]);j++) {
			if(k==p[j]) {
				karta=p[j+1];
			}
		}
	}
	else {
		int a=p[0];
		int duzina2=duzina+1;
		for(int j=1;j<duzina2;j++) {
			noviniz[i];
		}
		noviniz[duzina2] = 0;
		for(int j=1;j<duzina2;j++) {
			if(k==p[j]) {
				karta=p[j+1];
			}
		}
	}
	}
	cout << karta;
	return 0;
}