#include <iostream>
#include <vector>

int main()
{
	int num_cards, above_drawn_card, index_adc;

	std::cin >> num_cards >> above_drawn_card;

	std::vector<int> cards(num_cards);	

	for(int i = 0; i < num_cards; i++)
	{
		int input;
		std::cin >> input;
		if(input == above_drawn_card)
			index_adc = i;
		
		cards[i] = input;
	}

	if (cards[num_cards - 1] == above_drawn_card)
		std::cout << cards[0];
	else
		std::cout << cards[index_adc + 1];
	

	return 0;
}