#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> v[N];
long long a[N], b[N], dis[N], n, k, x, mx;
map<long long, long long> mp, mpp;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (mp[x] < mp[k]) mpp[x] = 1;
    mp[x]++;
    mx = max(mx, x);
  }
  for (int i = 1; i <= mx; i++)
    if (!mpp[i] && mp[i] >= mp[k] && i != k) return cout << i, 0;
  cout << "-1";
  return 0;
}
