#include <bits/stdc++.h>
using namespace std;
void func(void) {
  freopen("input.c", "r", stdin);
  freopen("output.c", "w", stdout);
}
const int N = 1e6 + 10;
long long a[N];
int main() {
  long long n, q, i, j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m,
                     fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000,
                     mn1 = 8000000000000000000;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == m) {
      ans++;
    } else {
      if (a[x] >= ans) {
        a[x]++;
      }
    }
  }
  for (int i = 1; i <= N - 2; i++) {
    if (m != i and a[i] >= ans) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
