#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int maxn = 100005, S = 1000000;
int n, A, cnt[maxn], a[maxn];
vector<int> ps[S + 5];
int main() {
  n = rd(), A = rd();
  for (int i = int(1); i <= (int)(n); i++) {
    a[i] = rd();
    ps[a[i]].push_back(i);
    cnt[i] = cnt[i - 1] + (a[i] == A);
  }
  for (int i = int(1); i <= (int)(S); i++) {
    if (i == A) continue;
    int cou = 0, flg = 1;
    for (int j = int(0); j <= (int)(ps[i].size() - 1); j++) {
      if (cnt[ps[i][j]] > cou) {
        flg = 0;
        break;
      }
      cou++;
    }
    if (cnt[n] > cou) flg = 0;
    if (flg) return rt(i), putchar('\n'), 0;
  }
  puts("-1");
}
