#include <bits/stdc++.h>
using namespace std;
map<int, int> p;
int main() {
  int n, m, x, i, s;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (p[x] < p[m]) p[x] = -1;
    p[x]++;
  }
  s = -1;
  for (i = 1; i <= 1000000; i++) {
    if (p[i] >= p[m] && i != m) s = i;
  }
  printf("%d\n", s);
  return 0;
}
