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[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int p = -1;
            string[] st = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                int x = int.Parse(st[i]);
                if (x == k)
                {
                    p = i;
                    break;
                }
            }
            Console.WriteLine(p != -1 && p < n - 1 ? st[p + 1] : st[0]);
        }
    }
}