#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
  int A, B, n;
  cin >> n >> A;
  int c[n];
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    if (a[c[i]] < a[A]) {
      a[c[i]] = -1;
    }
    if (a[c[i]] != -1) {
      a[c[i]]++;
    }
  }
  int ans = 0;
  for (int i = 1; i < 1000005; i++) {
    if (a[i] >= a[A] && i != A) {
      ans = i;
      break;
    }
  }
  if (ans == 0)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}
