#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using VI = vector<int>;
using pii = pair<int, int>;
template <typename A, typename B>
void smin(A &a, const B &b) {
  if (a > b) a = b;
}
template <typename A, typename B>
void smax(A &a, const B &b) {
  if (a < b) a = b;
}
int a[101010];
int cnt[1010101];
set<pii> s;
set<pii>::iterator it;
int main() {
  int n, A;
  scanf("%d %d", &n, &A);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    if (a[i] != A) s.insert({0, a[i]});
  }
  for (int i = 1; i <= n; i++) {
    int first = a[i];
    if (first == A)
      cnt[A]++;
    else {
      it = s.find({cnt[first], first});
      if (it != s.end()) {
        s.erase(it);
        s.insert({++cnt[first], first});
      }
    }
    while (!s.empty()) {
      it = s.begin();
      if (cnt[A] > it->first)
        s.erase(it);
      else
        break;
    }
  }
  if (s.empty())
    puts("-1");
  else
    printf("%d", s.begin()->second);
}
