#include <iostream>

using namespace std;

int main()
{
	int n, k, firstCard;
	cin >> n >> k >> firstCard;
	int i = 1;
	int output;
	if (firstCard == k)
	{
		cin >> output;
		i++;
	}
	for (i++; i <= n; i++)
	{
		int card;
		cin >> card;
		if (card == k)
		{
			if (i == n)
			{
				output = firstCard;
			}
			cin >> output;
			i++;
		}
	}
	cout << output;
}