#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  long long n = v.size();
  for (long long i = 0; i < n; i++) cin >> v[i];
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  cin >> p.first >> p.second;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &v) {
  long long n = v.size();
  for (long long i = 0; i < n; i++) cout << v[i] << " ";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &p) {
  cout << p.first << " " << p.second << " ";
  return out;
}
void solve() {
  long long n, k, i, a;
  cin >> n >> k;
  vector<long long> b(1000005);
  for (i = 0; i < n; i++) {
    cin >> a;
    if (b[a] >= b[k]) b[a]++;
  }
  for (i = 1; i <= 1000005; i++)
    if (i != k && b[i] >= b[k]) break;
  if (i == 1000005 + 1) i = -1;
  cout << i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
