#include <bits/stdc++.h>
using namespace std;
const int MM = 120000;
long long int m, n, k, p1, p2, p3, p, f, a[MM], cn[10 * MM], bl[10 * MM];
set<long long int> s[MM], sx;
vector<long long int> temp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    f += (a[i] == p1);
  }
  long long int cur = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == p1) {
      cur++;
      continue;
    }
    if (cn[a[i]] < cur) {
      bl[a[i]] = 1;
      cn[a[i]] = 0;
      continue;
    }
    cn[a[i]]++;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (cn[i] >= f && !bl[i] && i != p1) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
