#include <bits/stdc++.h>
int c[1100000];
int main() {
  long long i, n, a, m;
  int flag;
  while (scanf("%lld%lld", &n, &a) != EOF) {
    for (i = 1; i <= 1000000; i++) c[i] = 0;
    for (i = 1; i <= n; i++) {
      scanf("%lld", &m);
      if (c[m] >= c[a]) c[m]++;
    }
    flag = 0;
    for (i = 1; i <= 1000000; i++) {
      if (c[i] >= c[a] && i != a) {
        flag = 1;
        printf("%lld\n", i);
        break;
      }
    }
    if (flag == 0) printf("-1\n");
  }
}
