#include <bits/stdc++.h>
using namespace std;
int alist[100001] = {};
int blist[1000000] = {};
int tlist[1000000] = {};
int main() {
  int n, a;
  cin >> n >> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == a) {
      alist[i]++;
    }
    alist[i + 1] = alist[i];
    if (x != a) {
      blist[x]++;
      if (blist[x] > alist[i]) {
        tlist[x]++;
      } else {
        tlist[x] = -10000000;
      }
    }
  }
  bool found = false;
  for (int i = 0; i < 1000000; i++) {
    if (blist[i] >= alist[n] && tlist[i] > 0) {
      cout << i;
      found = true;
      break;
    }
  }
  if (!found) cout << -1;
}
