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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = Convert.ToInt32(s[0]);
            int k= Convert.ToInt32(s[1]);
            string[]s1 = Console.ReadLine().Split();
            int[] a = new int[s1.Length];
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s1[i]);
            }
            for (int i = 0; i < n; i++)
            {
                if (i + 1 != n)
                {
                    if (a[i] == k)
                    {
                        Console.WriteLine(a[i + 1]);
                        break;
                    }
                }
                else
                    Console.WriteLine(a[0]);
            }
        }
    }
}