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