#include <bits/stdc++.h>
using namespace std;
int n, A;
int a[100005];
map<int, int> mp;
map<int, set<int> > se;
set<int>::iterator it, itt;
set<int> re;
int main() {
  scanf("%d %d", &n, &A);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int now = 0;
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] != A) {
      it = se[mp[a[i]]].find(a[i]);
      if (it != se[mp[a[i]]].end()) se[mp[a[i]]].erase(it);
      mp[a[i]]++;
      se[mp[a[i]]].insert(a[i]);
      if (flag == 0) re.insert(a[i]);
    } else {
      now++;
      if (now == 1) flag = 1;
      for (it = re.begin(); it != re.end();) {
        if (mp[*it] < now) {
          re.erase(it++);
        } else
          it++;
      }
      if (re.size() == 0) {
        printf("-1\n");
        return 0;
      }
    }
  }
  printf("%d\n", *re.begin());
  return 0;
}
