#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, A;
  cin >> n >> A;
  int ans[1000003] = {0}, cnt_a = 0, Bf = 0, brk = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == A)
      cnt_a++;
    else if (ans[x] >= cnt_a) {
      ans[x]++;
    }
  }
  for (int i = 1; i < 1000001; i++) {
    if (ans[i] >= cnt_a and i != A) {
      brk = 0;
      Bf = i;
      break;
    }
  }
  if (!brk)
    cout << Bf << endl;
  else
    cout << -1 << endl;
  return 0;
}
