#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, a;
  cin >> n >> a;
  long long t[n], app[1000006] = {0};
  for (long long i = 0; i < n; i++) {
    cin >> t[i];
    if (t[i] == a)
      app[a]++;
    else
      app[t[i]] += (app[a] <= app[t[i]]);
  }
  for (long long i = 1; i < 1000006; i++) {
    if (i == a) continue;
    if (app[i] >= app[a]) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}
