#include <bits/stdc++.h>   using namespace std;   bool prime[1500000 + 10];   bool a[1500000 + 10];   int func(int N, int x) {     int i, ans = 0;     if (x == 2) return 0;     if (a[1]) return 1;     if (x >= 1500000) return -1;     for (i = 2; i <= x - 1; i++)       if (prime[i])         if (a[i])           ans++;         else           return -1;     return ans;   }   int main(void) {     int i, j, N, x, tmp;     for (i = 2; i < 1500000; i++) prime[i] = true;     for (i = 2; i * i < 1500000; i++)       if (prime[i])         for (j = i * i; j < 1500000; j += i) prime[j] = false;     scanf( %d%d , &N, &x);     for ((i) = 0; (i) < (int)(N); (i)++) {       scanf( %d , &tmp);       if (tmp < 1500000) a[tmp] = true;     }     int ans = func(N, x);     cout << ans << endl;     return 0;   }   