using System;

namespace Madjionicar_petlja
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split();
            int n = int.Parse(s1[0]);
            int k = int.Parse(s1[1]);
            int[] p = new int[n];
            string[] s2 = Console.ReadLine().Split();
            for(int i = 0; i < n; i++)
            {
                p[i] = int.Parse(s2[i]);
            }
            for(int i = 0; i < n; i++)
            {
                if(p[i] == k && i < n - 1)
                {
                    Console.WriteLine(p[i + 1]);
                }
                if(p[i] == k && i == n - 1)
                {
                    Console.WriteLine(p[0]);
                }
            }
        }
    }
}