#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, x, a[maxn], ans;
bool s[15 * maxn];
int main() {
  cin.sync_with_stdio(false);
  cin >> n >> x;
  if (x == 2) {
    cout << 0 << endl;
    return 0;
  }
  memset(s, true, sizeof(s));
  for (int i = 2; i <= x;) {
    if (x >= n * 15) break;
    for (long long j = i; i * j <= x; j++) s[i * j] = false;
    i++;
    while (i <= x && !s[i]) i++;
  }
  if (x <= n * 15)
    for (int i = 2; i < x; i++) ans += s[i];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) {
      cout << 1 << endl;
      return 0;
    }
    if (x <= n * 15 && a[i] <= x) s[a[i]] = false;
  }
  if (x >= n * 15) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 2; i < x; i++)
    if (s[i]) {
      cout << -1 << endl;
      return 0;
    }
  cout << ans << endl;
  return 0;
}
