#include <iostream>
using namespace std;
int
main ()
{
  int N, K, i, pi;
  cin >> N >> K;
  int karte[N];
  for (int b = 0; b < N; b++)
    {
      cin >> karte[b];
    }
  for (int a = 0; a <= N - 1; a++)
    {
      if (karte[a] == K)
	{
	  	  if(a == N - 1)
	  {
	      cout<<karte[0];
	  }
	      else
	      cout<< karte[a+1];
	  
	}

    }
}