#include <bits/stdc++.h>
using namespace std;
int n, x, p, ans;
int a[100010], v[2000010];
int main() {
  scanf("%d%d", &n, &x);
  if (x == 2) {
    puts("0");
    return 0;
  }
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  n = unique(a, a + n) - a;
  if (a[0] == 1) {
    puts("1");
    return 0;
  }
  if (x >= 20 * x) {
    puts("-1");
    return 0;
  }
  p = 0;
  ans = 0;
  for (int i = 2; i < x; i++)
    if (!v[i]) {
      while (p < n && a[p] != i) p++;
      if (p == n) {
        puts("-1");
        return 0;
      }
      for (int j = i + i; j < x; j += i) v[j] = 1;
      ans++;
    }
  printf("%d\n", ans);
}
