#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000200;
const int INF = 0x3f3f3f3f;
int a[maxn], ans[maxn], sum[maxn], vis[maxn];
int main() {
  int N, A;
  scanf("%d%d", &N, &A);
  memset(vis, 0, sizeof(vis));
  memset(ans, 0, sizeof(ans));
  vis[A] = 1;
  int t;
  for (int i = 1; i <= N; i++) {
    scanf("%d", &t);
    a[i] = t;
    if (ans[t] < ans[A]) {
      vis[t] = 1;
    }
    ans[t]++;
    if (ans[t] < ans[A]) vis[t] = 1;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (vis[i] == 0 && ans[i] >= ans[A]) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
