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

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            int n; int k;
            string s = Console.ReadLine();
            string[] using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            int n; int k;
            string s = Console.ReadLine();
            string[] s1 = s.Split(' ');
            n = Convert.ToInt32(s1[0]);
            k = Convert.ToInt32(s1[1]);
            int[] m = new int[n];
            int kp = 0;
            string t = Console.ReadLine();
            string[] t1 = s.Split(' ');
            for (int i = 0; i < n; i++)
            {
                m[i] = Convert.ToInt32(t1[i]);
                if (m[i] == k) kp = i;
            }
            if (k == m[n - 1])
            {
                Console.WriteLine(m[0]);
            }
            else Console.WriteLine(m[kp + 1]);
            
        }
    }
}
s1 = s.Split();
            n = Convert.ToInt32(s1[0]);
            k = Convert.ToInt32(s1[1]);
            int[] m = new int[n];
            int kp = 0;
            string t = Console.ReadLine();
            string[] t1 = s.Split();
            for (int i = 0; i < n; i++)
            {
                m[i] = Convert.ToInt32(t1[i]);
                if (m[i] == k) kp = i;
            }
            if (k == m[n - 1])
            {
                Console.WriteLine(m[0]);
            }
            else Console.WriteLine(m[kp + 1]);
            
        }
    }
}