#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 998244353;
int n, A;
int cnt[MX];
int main() {
  scanf("%d%d", &n, &A);
  set<pair<int, int> > w;
  for (int i = 1; i <= 1e6; i++) {
    w.insert(pair<int, int>(0, i));
  }
  for (int i = 1; i <= n; i++) {
    int c;
    scanf("%d", &c);
    auto iter = w.lower_bound(pair<int, int>(cnt[c], c));
    if (iter == w.end() || iter->second != c) continue;
    w.erase(iter);
    cnt[c]++;
    iter = w.insert(pair<int, int>(cnt[c], c)).first;
    if (c == A) {
      iter = w.upper_bound(pair<int, int>(cnt[c] - 1, INF));
      w.erase(w.begin(), iter);
    }
  }
  w.erase(pair<int, int>(cnt[A], A));
  auto iter = w.lower_bound(pair<int, int>(cnt[A], 0));
  if (iter == w.end())
    printf("-1\n");
  else
    printf("%d\n", iter->second);
  return 0;
}
