#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, alice;
  cin >> n >> alice;
  map<int, int> options;
  int alice_count = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x == alice) {
      ++alice_count;
      vector<int> to_delete;
      for (const auto &p : options) {
        if (p.second < alice_count) {
          to_delete.push_back(p.first);
        }
      }
      for (int val : to_delete) {
        options.erase(val);
      }
    } else if (alice_count == 0 || options.find(x) != options.end()) {
      ++options[x];
    }
  }
  if (options.empty()) {
    cout << "-1\n";
  } else {
    cout << (options.begin()->first) << "\n";
  }
  return 0;
}
