#include <iostream>
#include <cstring>
#include <climits>
#include <vector>

using namespace std;


int main()
{
	int n;
	cin >> n;
	int karta;
	cin >> karta;
	int  nizKarte[n] = {0};
	int mestoTrazeneKarte;
	for (int i = 0; i < n; i++)
	{
		cin >> nizKarte[i];
		if(nizKarte[i] == karta && i<n-1)
		{
		    cin>> nizKarte[i];
		    cout<< nizKarte[i];
		    return 0;
		}
		else if (nizKarte[i] == karta)
		{
		    cout<<nizKarte[0];
		    return 0;
		}
	}
	

}