#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool isPrime(long long n) {
  if (n < 2) return 0;
  if (n < 4) return 1;
  if (n % 2 == 0 or n % 3 == 0) return 0;
  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 or n % (i + 2) == 0) return 0;
  return 1;
}
long long modexpo(long long x, long long p) {
  long long res = 1;
  x = x % 1000000007;
  while (p) {
    if (p % 2) res = res * x;
    p >>= 1;
    x = x * x % 1000000007;
    res %= 1000000007;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, A;
    cin >> n >> A;
    long long a[n];
    map<long long, long long> m;
    long long c = 0;
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] != A) m[a[i]] = 0;
    }
    long long f = 0;
    for (long long i = 0; i < n; ++i) {
      if (a[i] != A && m.count(a[i])) {
        m[a[i]]++;
      } else if (a[i] == A) {
        c++;
        vector<long long> v;
        for (auto j : m) {
          if (j.second < c) {
            v.push_back(j.first);
          }
        }
        for (long long j : v) {
          m.erase(j);
        }
        if (m.size() == 0) {
          f = 1;
          break;
        }
      }
    }
    if (f) {
      cout << -1;
    } else {
      cout << m.begin()->first;
    }
    cout << "\n";
  }
}
