#include <bits/stdc++.h>
using namespace std;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long fpow(long long n, long long k, int p = (int)1e9 + 7) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
inline int inv(int a, int p = (int)1e9 + 7) { return fpow(a, p - 2, p); }
bool cmp(const pair<int, int> &p1, const pair<int, int> &p2) {
  if (p1.first == p2.first)
    return p1.second < p2.second;
  else
    return p1.first < p2.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, a;
  cin >> n >> a;
  map<int, int> vec;
  int val, mx = 0;
  for (int i = (1); i <= (n); ++i) {
    cin >> val;
    mx = max(val, mx);
    if (val == a)
      vec[a] += 1;
    else {
      if (vec[val] >= vec[a])
        vec[val] += 1;
      else
        vec[val] = -1;
    }
  }
  int flag = 1;
  for (int i = (1); i <= (mx); ++i) {
    if ((i != a) && (vec[i] >= vec[a])) {
      cout << i << endl;
      flag = 0;
      break;
    }
  }
  if (flag) cout << "-1\n";
  return 0;
}
