#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  int c[n];
  for (int i = 0; i < n; i++) cin >> c[i];
  int cnt[1000001] = {0};
  set<int> s;
  int appa = 0;
  set<int>::iterator itr;
  for (int i = 0; i < n; i++) {
    if (c[i] != a) {
      if (appa == 0) {
        s.insert(c[i]);
        cnt[c[i]]++;
      } else {
        if (cnt[c[i]] != 0) cnt[c[i]]++;
      }
    } else {
      appa++;
      vector<int> v;
      v.clear();
      for (itr = s.begin(); itr != s.end(); itr++) {
        if (cnt[*itr] < appa) v.push_back(*itr);
      }
      for (int j = 0; j < v.size(); j++) {
        cnt[c[i]] = 0;
        s.erase(v[j]);
      }
      if (s.size() == 0) {
        cout << "-1\n";
        return 0;
      }
    }
  }
  for (set<int>::iterator itr = s.begin(); itr != s.end(); itr++) {
    cout << (*itr) << endl;
    return 0;
  }
}
