#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i,n,k,p,*a;
	scanf("%d%d",&n,&k);
	a=calloc(n,sizeof(int));
	for(i=0;i<n;i++)
	{
		scanf("%d",a+i);
		if(*(a+i)==k){p=i;}
	}
	if(p==n-1){printf("%d",*a);}
    else
	{
		if(p==0){printf("%d",*(a+n-1));}
		else{printf("%d",*(a+p-1));}
	}
	return 0;
}