#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 1;
int counter[MAX];
int color[MAX];
int main(void) {
  int num, choose;
  scanf("%d%d", &num, &choose);
  for (int i = 0; i < num; i++) scanf("%d", &color[i]);
  for (int i = 0; i < num; i++) {
    if (color[i] == choose)
      counter[choose]++;
    else if (counter[color[i]] >= counter[choose])
      counter[color[i]]++;
  }
  int ans = -1;
  for (int i = 1; i < MAX; i++) {
    if (counter[i] >= counter[choose] && i != choose) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
