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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x1 = Console.ReadLine().Split();
            int n = int.Parse(x1[0]);
            int  k = int.Parse(x1[1]);
            string[] x2 = Console.ReadLine().Split();
            int[] N = new int[n];int a = 0;
            for(int i = 0; i<n; i++)
            {
                N[i] =int.Parse( x2[i]);
                if (N[i] == k) a = i;
            }
            
            if (a + 1 <= n - 1)
            {
                Console.WriteLine(N[a + 1]);
            }
            else if (a + 1 > n - 1)
            {
                Console.WriteLine(N[0]);
            }
        }
    }
}