#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  const int maxColor = int(1e6);
  int n, a;
  cin >> n >> a;
  vector<bool> available(maxColor + 1, true);
  vector<int> counts(maxColor + 1, 0);
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    if (c != a) {
      if (counts[c] < counts[a]) available[c] = false;
    }
    counts[c]++;
  }
  for (int i = 1; i <= maxColor; i++) {
    if (available[i] && counts[i] >= counts[a] && a != i)
      return cout << i << '\n', 0;
  }
  cout << -1 << '\n';
  return 0;
}
