#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, a, x;
  cin >> n >> a;
  bool found = false;
  set<long long> s;
  map<long long, long long> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == a) {
      found = true;
      m[a]++;
      vector<int> temp;
      for (auto v : s) {
        if (m[v] < m[a]) temp.push_back(v);
      }
      for (auto v : temp) s.erase(v);
      continue;
    } else {
      if (found == false)
        s.insert(x), m[x]++;
      else {
        if (s.find(x) != s.end()) m[x]++, s.insert(x);
      }
    }
  }
  if (s.size() == 0)
    cout << -1;
  else
    cout << *(s.begin());
  return 0;
}
