#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 7;
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = a * a % M) ret = 1ll * ret * a % M;
  return ret;
}
int n, m;
int A, a[maxn], cnt, ans;
int i, j, k, t;
int main() {
  scanf("%d%d", &n, &A);
  for (i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t == A)
      cnt++;
    else if (a[t] >= cnt)
      a[t]++;
  }
  ans = -1;
  for (i = 1; i <= 1000000; i++)
    if (a[i] >= cnt && i != A) ans = i;
  printf("%d", ans);
}
