using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Petlja
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] unos = Console.ReadLine().Split();
			int n = int.Parse(unos[0]);
			int k = int.Parse(unos[1]);
			int[] niz = new int[n];

			unos = Console.ReadLine().Split();
			for (int i = 0; i < n; i++)
			{
				niz[i] = int.Parse(unos[i]);
			}

			for (int i = 0; i < n; i++)
			{
				if(niz[i] == k)
				{
					if(i == n-1)
						Console.WriteLine(niz[0]);
					else
						Console.WriteLine(niz[i+1]);
				}
			}
		}
	}
}