#include <iostream>

using namespace std;

int main()
{
    int n, k;
	int niz[20000];
	int j = 0;
	int rez;

    cin >> n >> k;

	for (size_t i = 0; i < n; i++)
	{
		cin >> niz[i];
	}

	while (k != niz[j])
	{
		j++;
	}

	if (j < n - 1)
	{
		rez = niz[j + 1];
	}
	else rez = niz[0];

	cout << rez;






}