#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
set<int> s[1000000];
int main() {
  int n, a, count, i, ele;
  scanf("%d %d", &n, &a);
  count = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &ele);
    if (ele != a) {
      if (m[ele] >= count) m[ele] = m[ele] + 1;
    } else
      count++;
  }
  for (map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {
    if (it->second >= count) {
      printf("%d", it->first);
      return 0;
    }
  }
  printf("-1");
  return 0;
}
