#include <bits/stdc++.h>
using namespace std;
int n, a;
int t[1000001];
vector<int> jok;
int adb = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> a;
  for (int i = 1; i <= 1000000; i++)
    if (i != a) jok.push_back(i);
  for (int i = 1; i <= n && jok.size() >= 0; i++) {
    int c;
    cin >> c;
    if (c != a)
      t[c] += 1;
    else {
      adb += 1;
      vector<int> akt = {};
      for (auto s : jok)
        if (t[s] >= adb) akt.push_back(s);
      jok = akt;
    }
  }
  if (jok.size() == 0)
    cout << -1;
  else
    cout << jok[0];
  return 0;
}
