#include <bits/stdc++.h>
using namespace std;
const int MX = 3 * 1e5 + 10;
const double PI = acos(-1.0), EPS = 1e-9;
int N, x;
int rep[1000002];
int ar[MX];
multiset<pair<int, int> > ms;
int main() {
  scanf("%d%d", &N, &x);
  for (int i = 0; i < N; i++) {
    scanf("%d", &ar[i]);
  }
  ar[N] = x;
  for (int i = 0; i <= N; i++) {
    if (ar[i] == x) {
      while (ms.size()) {
        pair<int, int> p = *ms.begin();
        if (p.first >= rep[x]) break;
        rep[p.second] = -1;
        ms.erase(p);
      }
      rep[x]++;
    } else {
      int r = rep[ar[i]];
      if (r < rep[x]) {
        rep[ar[i]] = -1;
        continue;
      }
      ms.erase(make_pair(r, ar[i]));
      ms.insert(make_pair(r + 1, ar[i]));
      rep[ar[i]]++;
    }
  }
  if (ms.size()) {
    pair<int, int> p = *ms.begin();
    cout << p.second;
  } else
    cout << -1;
  return 0;
}
