#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, maxNum = 1e6 + 10;
int c[maxn], _count[maxNum], _countA;
int main() {
  int n, A;
  cin >> n >> A;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    if (c[i] == A) {
      _countA++;
      continue;
    }
    if (_count[c[i]] - 1 < _countA - 1) {
      _count[c[i]] = -100010;
    }
    _count[c[i]]++;
    if (_count[c[i]] < _countA) {
      _count[c[i]] = -100010;
    }
  }
  for (int p = 1; p <= n; p++) {
    if (c[p] != A && _count[c[p]] >= _countA) {
      cout << c[p] << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
