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

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