#include<stdio.h>

int main()
{
	int n, k, ind;
	scanf("%d%d", &n, &k);
	int niz[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &niz[i]);	
		if (niz[i] == k)
			ind = i;
	}
	if (ind + 1 == n)
		printf("%d", niz[0]);
	else
		printf("%d", niz[ind + 1]);
}