#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long MAX = 1e9 + 7;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 7;
long long n, a, w = 0;
long long s[maxn];
map<long long, long long> mp, ma;
set<long long> q;
int main() {
  cin >> n >> a;
  long long w = 0, b = 0, flag = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    if (mp[s[i]] < mp[a]) ma[s[i]] = 1;
    mp[s[i]]++;
  }
  for (long long i = 0; i < n; i++) {
    if (ma[s[i]] == 0 && mp[s[i]] >= mp[a] && s[i] != a) {
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
