#include <bits/stdc++.h>
using namespace std;
void setup() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(time(0));
}
const int N = 1e8 + 228;
bitset<N> pr;
signed main() {
  setup();
  int n, x;
  cin >> n >> x;
  set<int> a;
  for (int i = 0; i < n; ++i) {
    int b;
    cin >> b;
    a.insert(b);
  }
  if (a.count(1) && x != 2) {
    cout << 1;
    return 0;
  }
  int ans = 0;
  for (int i = 2; i < min(N, x); ++i) {
    if (!pr[i]) {
      ++ans;
      if (!a.count(i)) {
        cout << -1;
        return 0;
      }
      if ((long long)i * i >= N) continue;
      for (int j = i * i; j < min(N, x); j += i) pr[j] = true;
    }
  }
  cout << ans;
}
