#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

  int n, k;
  int * p =  (int *) malloc(n*sizeof(int));

  scanf("%d%d", &n, &k);

  for(int i = 0; i < n; i++){
    scanf("%d", &p[i]);
  }

  int x = 0;

  while ( p[x] != k){
    x++;
  }

  if (x == n-1) printf("%d", p[0]);
  else printf("%d", p[x+1]);
}