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

namespace ConsoleApplication2
{
    class Mango
    {
        static void Scan(int n, int[] x)
        {
            string[] s = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                x[i] = int.Parse(s[i]);
            }
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int a = 0;
            int[] x = new int[n];
            Scan(n, x);
            for (int i = 0; i < n; i++)
            {
                if (x[i] == m && i != n - 1)
                {
                    a = x[i + 1];
                    break;
                }
                else if (x[i] == m && i == n - 1)
                {
                    a = x[0];
                    break;
                }
            }
            Console.WriteLine(a);
        }
    }
}