#include <iostream>
#include <vector>
int main()
{
	int N; int K; std::vector<int> spil; int temp;
	std::cin >> N >> K;
	for (int i = 0; i < N; i = i + 1)
	{	
		int x;
		std::cin >> x;
		spil.push_back(x);
	}
	for (int j = 0; j < N; j = j + 1)
	{
		temp = j;
		if (spil[j] == K)
		{
			break;
		}

	}
	if (K == spil[spil.size() - 1])
	{
		std::cout << spil[0];
	}
	else 
	{
		std::cout << spil[temp + 1];
	}
}