#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int arr[100001];
int arr2[1000001];
bool arr3[1000001];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= 1000000; i++) arr3[i] = true;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr2[arr[i]] < arr2[m]) arr3[arr[i]] = false;
    arr2[arr[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == m) {
      printf("-1");
      return 0;
    }
    if (arr2[arr[i]] >= arr2[m] && arr3[arr[i]] == true) {
      printf("%d", arr[i]);
      return 0;
    }
  }
  return 0;
}
