using System;

class Program {
  public static void Main (string[] args) {
    string[] s = Console.ReadLine().Split();
    int N = Convert.ToInt32(s[0]);
    int K = Convert.ToInt32(s[1]);

    int[] karte = new int [N];
    s = Console.ReadLine().Split();
    for(int i = 0; i < N; i++)
    {
      karte[i] = Convert.ToInt32(s[i]);
    }

    if(K == karte[karte.Length - 1])
    {
      Console.WriteLine(karte[0]);
    }
    else
    {
      for(int i = 0; i < karte.Length - 1; i++)
      {
        if(karte[i] == K)
        {
          Console.WriteLine(karte[i + 1]);
          return;
        } 
      }
    }
    
  }
}