#include <bits/stdc++.h>
using namespace std;
int f[10000010], a[10000010], num[10000010], n, k;
inline void setIO() {
  freopen("data.in", "r", stdin);
  freopen("data.out", "w", stdout);
}
int main() {
  memset(f, 0, sizeof(f));
  memset(num, 0, sizeof(num));
  scanf("%d%d", &n, &k);
  f[k] = 1;
  for (int(i) = (1); (i) <= (n); (i)++) {
    int t;
    scanf("%d", &t);
    a[i] = t;
    if (num[t] < num[k]) f[t] = 1;
    num[t]++;
    if (num[t] < num[k]) f[t] = 1;
  }
  for (int(i) = (1); (i) <= (1000000); (i)++) {
    if (f[i] == 0 && num[i] >= num[k]) {
      printf("%d\n", i);
      return 0;
    }
  }
  puts("-1");
  return 0;
}
