#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int inf = 2e9;
const long long linf = 2e18;
using namespace std;
const int maxn = 2e6 + 5;
int num[maxn];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; n >= i; i++) {
    int tmp;
    scanf("%d", &tmp);
    if (num[tmp] == -1)
      continue;
    else if (tmp == k)
      num[tmp]++;
    else {
      if (num[tmp] < num[k])
        num[tmp] = -1;
      else
        num[tmp]++;
    }
  }
  int ok = 0;
  for (int i = 1; 1000000 >= i; i++) {
    if (num[i] >= num[k] && i != k) {
      ok = i;
      break;
    }
  }
  if (ok)
    printf("%d\n", ok);
  else
    printf("-1\n");
  return 0;
}
