#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long maxn = 1e6 + 1;
vector<long long> v[maxn];
int main() {
  long long n, a, h = 0;
  cin >> n >> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x == a) {
      h++;
      continue;
    }
    v[x].push_back(h);
  }
  for (long long i = 1; i <= maxn - 1; i++) {
    if (i == a) continue;
    if ((v[i]).size() < h) continue;
    bool yes = 1;
    for (long long j = 0; j < (v[i]).size(); j++) {
      if (j < v[i][j]) {
        yes = 0;
        break;
      }
    }
    if (yes) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
