#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, int> mp;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    if (mp[x] >= mp[m]) mp[x]++;
  }
  for (int i = 1; i <= 1000000; i++)
    if (mp[i] >= mp[m] && i != m) return printf("%d", i), 0;
  puts("-1");
  return 0;
}
