using System;
using System.IO;
using System.Text;

namespace Madionicar
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader(Console.OpenStandardInput(), Encoding.UTF8, false, 960008));
            string[] values = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(values[0]);
            int k = Convert.ToInt32(values[1]);
            string[] niz = Console.ReadLine().Split(' ');
            int[] karte = new int[n];
            for (int i = 0; i < n; i++)
            {
                karte[i] = Convert.ToInt32(niz[i]);
            }
            for(int i = 0;i < n; i++)
            {
                if (karte[i] == k)
                {
                    if (i + 1 != n)
                    {
                        Console.Write(karte[i + 1]);
                    }
                    else
                    {
                        Console.Write(karte[0]);
                    }
                    break;
                }
            }
        }
    }
}