#include #define maxx(a, b, c) max(max(a, b), c) #define minn(a, b, c) min(min(a, b), c) #define between(x, l, r) (x >= l && x <= r) #define point(a, b) ((a - 1) * m + b) #define y second #define x first using namespace std; const int N = 1000010; typedef long long LL; LL primes[N], cnt; bool st[N]; LL p[N], check[N]; void get_primes(int n) // 线性筛质数 { for (int i = 2; i <= n; i ++ ) { if (!st[i]) primes[cnt ++ ] = i; for (int j = 0; primes[j] <= n / i; j ++ ) { st[primes[j] * i] = true; if (i % primes[j] == 0) break; } } } signed main() { LL l, r; cin >> l >> r; //auto now = clock(); LL d = pow(r, 1.0 / 3) + 2; // 筛根号三次内的数 get_primes(d); // O(n) for (int i = 0; i <= r - l; i ++ ) p[i] = l + i; // O(n) int res = r - l + 1; for (int i = 0; i < cnt; i ++ ) // O(nloglogn * logn) { LL start = (primes[i] - l % primes[i]) % primes[i]; //if(i == 1) cout << start << '\n'; for (int j = start; j <= r - l; j += primes[i]) { int tmp = 0; while (p[j] % primes[i] == 0) { p[j] /= primes[i]; tmp ++ ; } if(tmp >= 2 && !check[j]) check[j] = 1, res -- ; } } for (int i = 0; i <= r - l; i ++ ) { if(check[i] || p[i] == 1) continue; LL k = sqrt(p[i]); if(k * k == p[i]) res -- ; } cout << res << '\n'; return 0; } /* 607148 */