#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 10;
const int MAX_C = 1e6 + 10;
int n, A;
int c[MAX];
int last[MAX_C], cnt[MAX_C];
bool lost[MAX_C];
void init() {
  cin >> n >> A;
  for (int i = 1; i <= n; i++) cin >> c[i];
}
void process() {
  for (int i = 1; i <= n; i++)
    if (!lost[c[i]]) {
      if (c[i] == A) {
        cnt[A]++;
        last[A] = i;
        continue;
      }
      if (cnt[c[i]] < cnt[A]) {
        lost[c[i]] = true;
        continue;
      }
      cnt[c[i]]++;
      last[c[i]] = i;
    }
  for (int i = 1; i <= MAX_C - 10; i++)
    if (last[i] < last[A] && !lost[i]) {
      if (cnt[i] < cnt[A]) {
        lost[i] = true;
      }
    }
  for (int i = 1; i <= MAX_C - 10; i++)
    if (i != A && !lost[i]) {
      cout << i;
      return;
    }
  cout << "-1";
}
int main() {
  ios_base::sync_with_stdio(false);
  init();
  process();
}
