#include <bits/stdc++.h>
using namespace std;
int n, a;
vector<int> car[1000010];
int main() {
  cin >> n >> a;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    car[t].push_back(i);
  }
  for (int i = 1; i <= 1000000; i++) {
    if (a == i) continue;
    int j;
    for (j = 0; j < car[i].size(); j++) {
      int cur =
          lower_bound(car[a].begin(), car[a].end(), car[i][j]) - car[a].begin();
      if (cur > j) break;
    }
    if (j >= car[i].size() && car[i].size() >= car[a].size()) {
      cout << i;
      exit(0);
    }
  }
  cout << -1;
  return 0;
}
