#include <bits/stdc++.h>
long long int pow1(long long int, long long int);
using namespace std;
int n, a, i, c, visit[1000005], cnt[1000005];
multiset<int> ms[1000005];
int main() {
  multiset<int>::iterator itr;
  cin >> n >> a;
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < n; ++i) {
    cin >> c;
    visit[c] = 1;
    ms[c].insert(cnt[c] - cnt[a]);
    cnt[c]++;
    ms[c].insert(cnt[c] - cnt[a]);
  }
  for (i = 0; i < 1000005; ++i) {
    ms[i].insert(cnt[i] - cnt[a]);
    itr = ms[i].begin();
    if (visit[i] == 1 && *itr >= 0 && i != a) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans * a;
    }
    a = a * a;
    b = b >> 1;
  }
  return ans;
}
