using System;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            string[] s = Console.ReadLine().Split();
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            s = Console.ReadLine().Split();

            for (int i = 0; i < s.Length; i++)
                ht.Add(int.Parse(s[i]), int.Parse(s[i < s.Length-1 ? (i + 1) : 0]));

            Console.WriteLine(ht[K]);
        }
    }
}