using System;


namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Convert.ToString(Console.ReadLine());
            String u = Convert.ToString(Console.ReadLine());
            String[] o = new string[2];
            o = s.Split();
            int duz = Convert.ToInt32(o[0]);
            String[]l = new String[duz];
            l = u.Split();
            int p = Convert.ToInt32(l[0]);
            if (p == int.Parse(o[1]))
            {
                 Console.WriteLine (Convert.ToInt32 (l[1]));
                
            }
            else
            {
                Console.WriteLine(p);
            }
        }
    }
}