#include <bits/stdc++.h>
using namespace std;
int n, c;
int tr;
map<int, int> r;
bool out[1000100];
bool in[1000100];
int num;
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num != c) {
      if (tr > r[num]) {
        out[num] = true;
      }
    }
    if (num == c) {
      tr++;
    } else {
      r[num]++;
      in[num] = true;
    }
  }
  for (int i = 1; i <= 1000000; i++) {
    if (in[i] && !out[i] && r[i] >= tr) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
