#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int b[1000010];
int main() {
  int n, A;
  cin >> n >> A;
  int w = 0;
  for (int i = 0; i < n; i++) {
    int q;
    cin >> q;
    if (q == A)
      w++;
    else if (b[q] >= w)
      b[q]++;
  }
  for (int i = 1; i < 1000010; i++)
    if (b[i] >= w && i != A) {
      cout << i;
      return 0;
    }
  cout << "-1";
  return 0;
}
