#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;
int n, arr[nax];
int main() {
  set<int> set1;
  map<int, int> map1;
  int a, ans;
  cin >> n >> a;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == a) {
      while (arr[i] == a) {
        cnt++;
        i++;
      }
      i--;
      set<int> set2;
      for (auto x : set1) {
        if (map1[x] < cnt) set2.insert(x);
      }
      for (auto x : set2) set1.erase(x);
      if (set1.empty() == true) {
        cout << -1;
        return 0;
      }
    } else {
      map1[arr[i]]++;
      if (cnt == 0) set1.insert(arr[i]);
    }
  }
  cout << *(set1.begin());
  return 0;
}
