#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 10;
int sum[N << 2];
int add[N << 2];
int ans[N << 2];
void pushup(int root, int l, int r) {
  if (l == r) return;
  sum[root] = sum[root << 1] + sum[root << 1 | 1];
}
void pushdown(int root, int l, int r) {
  if (add[root] == 0) return;
  if (l == r) return;
  add[root << 1] += add[root];
  add[root << 1 | 1] += add[root];
  sum[root << 1] += add[root];
  sum[root << 1 | 1] += add[root];
  add[root] = 0;
}
void build(int root, int l, int r) {
  sum[root] = add[root] = 0;
  if (l == r) {
    return;
  }
  int mid = (l + r) >> 1;
  build(root << 1, l, mid);
  build(root << 1 | 1, mid + 1, r);
  pushup(root, l, r);
  return;
}
void update(int root, int l, int r, int ql, int qr, int x) {
  if (l == ql && r == qr) {
    sum[root] += x;
    add[root] += x;
    return;
  }
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  if (qr <= mid)
    update(root << 1, l, mid, ql, qr, x);
  else if (ql > mid)
    update(root << 1 | 1, mid + 1, r, ql, qr, x);
  else {
    update(root << 1, l, mid, ql, mid, x);
    update(root << 1 | 1, mid + 1, r, mid + 1, qr, x);
  }
  pushup(root, l, r);
  return;
}
int query(int root, int l, int r, int ql, int qr) {
  if (l == ql && r == qr) {
    return sum[root];
  }
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  if (qr <= mid)
    return query(root << 1, l, mid, ql, qr);
  else if (ql > mid)
    return query(root << 1 | 1, mid + 1, r, ql, qr);
  else {
    return query(root << 1, l, mid, ql, mid) +
           query(root << 1 | 1, mid + 1, r, mid + 1, qr);
  }
}
void travel(int root, int l, int r) {
  if (l == r) {
    ans[l] = sum[l];
    return;
  }
  pushdown(root, l, r);
  int mid = (l + r) >> 1;
  travel(root << 1, l, mid);
  travel(root << 1 | 1, mid + 1, r);
  return;
}
int main(void) {
  int n, A, B;
  scanf("%d%d", &n, &A);
  int now = 0;
  for (int i = 0; i < n; i++) {
    int c;
    scanf("%d", &c);
    if (c == A) {
      now++;
    } else {
      if (ans[c] - now >= 0) {
        ans[c]++;
      }
    }
  }
  for (int i = 1; i <= 1000000; i++) {
    if (ans[i] - now >= 0 && i != A) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
