#include <bits/stdc++.h>
using namespace std;
const long long SIZE = 1300000ll;
int ps, p[110000], a[110000];
bool b[SIZE];
void init() {
  for (long long i = 2; i < SIZE; i++)
    if (!b[i]) {
      p[ps++] = i;
      for (long long j = i * i; j < SIZE; j += i) b[j] = true;
    }
}
int main() {
  init();
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  if (a[0] == 1) {
    if (x == 2)
      puts("0");
    else
      puts("1");
    return 0;
  }
  int i, j;
  for (i = j = 0; x > p[i] && i < n; i++) {
    while (j < n && a[j] < p[i]) j++;
    if (j == n || a[j] > p[i]) break;
  }
  if (x <= p[i])
    printf("%d\n", i);
  else
    puts("-1");
}
