#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  int s[n];
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  if (s[0] == a) {
    cout << -1;
    return 0;
  } else {
    map<int, int> mm;
    map<int, int> flag, cnt2;
    flag[a] = -1;
    int cnt1 = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == a) {
        cnt1++;
      }
      mm[s[i]]++;
      if (cnt1 < mm[s[i]]) {
        cnt2[s[i]]++;
      } else {
        flag[s[i]] = -1;
      }
    }
    for (auto i : mm) {
      if (flag[i.first] == 0 && cnt2[i.first] >= cnt1) {
        cout << i.first;
        return 0;
      }
    }
    cout << -1;
  }
}
