#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k; cin >> n >> k;
	vector<int> elements(n);
	vector<int> card_bellow(n + 1, -1);
	for (int i = 0; i < n; i++)
		cin >> elements[i];
	for (int i = 0; i < n; i++)
	{
		if (i + 1 < n)
		{
			card_bellow[elements[i]] = elements[i + 1];
		}
	}

	if (card_bellow[k] == -1)
		cout << elements.front() << "\n";
	
	else
		cout << card_bellow[k] << "\n";

	return 0;
}