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

namespace Madjionicar
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int n = int.Parse(str[0]);
            int k = int.Parse(str[1]);
            str = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(str[i]);
            int b = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == k)
                    b = i;
            }
            if (b != (a.Length - 1))
                Console.WriteLine(a[b + 1]);
            else
                Console.WriteLine(a[0]);
        }
    }
}