using System;

namespace Takmicenje_2___18._12._2021_
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] red = Console.ReadLine().Split();
            int n = Convert.ToInt32(red[0]);
            int k = Convert.ToInt32(red[1]);
            string[] red2 = Console.ReadLine().Split();
            int[] niz = new int[n];
            for (int i=0;i<red2.Length;i++)
            {
                niz[i] = Convert.ToInt32(red2[i]);
            }
            for (int i=0;i<n;i++)
            {
                if (niz[i]==k)
                {
                    if (i == n - 1) Console.WriteLine(niz[0]);
                    else Console.WriteLine(niz[i + 1]);
                }
            }

        }
    }
}