#include <bits/stdc++.h>
using namespace std;
int n, a;
vector<int> col[1000005];
int main() {
  cin >> n >> a;
  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    col[tmp].push_back(i + 1);
  }
  int len = col[a].size();
  for (int i = 1; i <= 1000000; i++) {
    if (i == a) continue;
    if (col[i].size() >= col[a].size()) {
      int j = 0, k = 0;
      for (j = 0; j < len; j++) {
        while (k < len && col[i][k] < col[a][j]) k++;
        if (k < j + 1) break;
      }
      if (j == len) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << "-1\n";
  return 0;
}
