#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int a[MAXN];
int b[MAXN];
set<int> set1, set2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, A;
  cin >> n >> A;
  int f = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x != A) {
      if (!f || set2.count(x)) {
        set1.insert(x);
        a[x]++;
      }
    } else {
      f = 1;
      int cnt = 0;
      for (auto it : set2) {
        a[it]--;
        if (a[it] == 0) b[cnt++] = it;
      }
      for (int j = 0; j < cnt; j++) set2.erase(b[j]);
      set2.insert(set1.begin(), set1.end());
      set1.clear();
    }
  }
  if (f) {
    if (set2.empty())
      cout << "-1" << endl;
    else
      cout << *set2.begin() << endl;
  } else {
    cout << 1001 << endl;
  }
  return 0;
}
