#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;
int c[N];
map<int, int> cnt;
void solve() {
  int n, A;
  scanf("%d %d", &n, &A);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  if (c[0] == A) {
    printf("-1\n");
    return;
  }
  int now = 0;
  set<int> bad;
  for (int i = 0; i < n; ++i) {
    now += c[i] == A;
    if (c[i] != A) {
      if (cnt[c[i]] < now) {
        bad.insert(c[i]);
      }
      ++cnt[c[i]];
    }
  }
  for (auto i : cnt) {
    if (bad.count(i.first) == 0 && i.second >= now) {
      printf("%d\n", i.first);
      return;
    }
  }
  printf("-1\n");
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
