#include <iostream>

using namespace std;

int main()
{
	
	int n, k;
	cin >> n >> k;
	
	int a[n];
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	int odg = 0;
	
	for (int i = 0; i < n; i++)
	{
		if (a[i] == k && a[i] != a[n-1] ) odg = a[i+1];
		
		else if (a[i] == k && a[i] == a[n-1]) odg =a[0];		
	}
	
	
	cout << odg << endl;
	
	return 0;
}