#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int n, A, app[MAX], c[MAX];
vector<int> pos[(int)1e6 + 6];
int main() {
  scanf("%d %d", &n, &A);
  for (int i = int(1); i < int(n + 1); i++) {
    scanf("%d", c + i);
    app[i] = app[i - 1] + (c[i] == A);
    pos[c[i]].push_back(i);
  }
  int ans = -1;
  for (int i = int(1); i < int((int)1e6 + 1); i++) {
    if (i == A) {
      continue;
    }
    int total = 0;
    bool good = true;
    for (auto &each : pos[i]) {
      if (app[each] > total) {
        good = false;
        break;
      }
      total++;
    }
    if (app[n] > total) {
      good = false;
    }
    if (good) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
