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

namespace Zadatak1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            int[] spil = new int[N];
            string[] r = Console.ReadLine().Split();
            int brojac = 0;
            for (int i = 0; i < N; i++)
            {
                spil[i] = int.Parse(r[i]);
                if (K == spil[i])
                    brojac = i;
            }
            int karta = 0;
            if (brojac == N - 1)
            {
                karta = spil[0];
            }
            else
            {
                karta = spil[brojac + 1];
            }
            Console.WriteLine(karta);
        }
    }
}