#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e+5;
int n, a, b, temp;
int num[maxn * 10 + 5];
queue<int> q;
int main() {
  scanf("%d %d", &n, &a);
  for (int i = 1; i <= maxn * 10; i++)
    if (i != a) q.push(i);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &temp);
    if (temp != a)
      num[temp]++;
    else {
      int s = q.size();
      for (int i = 1; i <= s; i++) {
        int now = q.front();
        q.pop();
        num[now]--;
        if (num[now] >= 0) q.push(now);
      }
    }
  }
  if (q.size() != 0)
    cout << q.front() << endl;
  else
    cout << "-1\n";
  return 0;
}
