#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
bool prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<pair<long long, long long> > s;
  for (long long i = 1; i <= 1000000; i++) {
    if (i == x) continue;
    s.insert({0, i});
  }
  long long c[1000006] = {0};
  for (long long i = 0; i < n; i++) {
    c[a[i]]++;
    if (a[i] != x && s.find({c[a[i]] - 1, a[i]}) != s.end()) {
      s.erase({c[a[i]] - 1, a[i]});
      s.insert({c[a[i]], a[i]});
    }
    while (!s.empty() && s.begin()->first < c[x]) {
      s.erase(s.begin());
    }
  }
  if (s.empty())
    cout << -1;
  else
    cout << s.begin()->second;
  return 0;
}
