#include <bits/stdc++.h>
using namespace std;
int n, B, angka[1000005], maks, curr;
bool go[1000005];
int main() {
  cin >> n >> B;
  for (int x = 1; x <= n; x++) {
    int a;
    cin >> a;
    if (a == B && maks < angka[a] + 1) {
      cout << -1 << endl;
      return 0;
    }
    if (angka[B] <= angka[a]) {
      go[a] = true;
      if (maks < angka[a] + 1) {
        maks = angka[a] + 1;
        curr = a;
      }
    } else {
      go[a] = false;
    }
    if (go[a]) angka[a]++;
  }
  cout << curr << endl;
}
