#include <bits/stdc++.h>
using namespace std;
bool sortin(const pair<long long int, long long int> &e,
            const pair<long long int, long long int> &f) {
  return (e.first < f.first);
}
long long int a, b, c, i, j, k, l, m, n, p, q, r, x, y, z, ts, mn = 10e17,
                                                               mod = 10e8 + 7;
long long int ar[1000002], br[1000002], xr[1000002];
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  cin >> n >> a;
  for (long long int i = 1; i <= n; i++) {
    cin >> p;
    ar[i] = ar[i - 1] + (p == a);
    if (br[p] < ar[i]) br[p] = -1e18;
    if (p != a) br[p]++;
  }
  for (long long int i = 1; i <= 1000002; i++) {
    if (i != a and br[i] >= ar[n]) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}
