#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
int cnt[N];
vector<int> v[N];
int main() {
  long n, a, tp;
  cin >> n >> a;
  int i;
  for (i = 1; i <= n; i++) {
    cin >> tp;
    cnt[i] = cnt[i - 1] + (tp == a);
    v[tp].push_back(i);
  }
  for (i = 1; i <= N - 2; i++) {
    if (i == a) continue;
    int tot = 0;
    bool f = 1;
    for (auto j : v[i]) {
      if (tot < cnt[j]) {
        f = 0;
        break;
      }
      tot++;
    }
    if (f && tot >= cnt[n]) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
