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

class cppboljiodcs
{
    static void Main()
    {
        string[] unos = Console.ReadLine().Split();
        int n = int.Parse(unos[0]);
        int k = int.Parse(unos[1]);

        List<int> karta = new List<int>();
        string[] unos2 = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            karta.Add(int.Parse(unos2[i]));
        }

        int indexOdK = karta.IndexOf(k);
        if (indexOdK == n - 1)
        {
            Console.WriteLine(karta[0]);
        }
        else
        {
            Console.WriteLine(karta[indexOdK + 1]);
        }

    }
}