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

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