#include using namespace std; using u64 = uint64_t; constexpr int rt = 2e6, rt2 = (u64)1e18 / rt / rt, width = 1e6 + 1; bool isprime[rt + 1], ans_[width]; void sieve_of_atkin(){ constexpr int N = 2e6, sqrtN = 1414; int n; for(int z = 1; z <= 5; z += 4){ for(int y = z; y <= sqrtN; y += 6){ for(int x = 1; x <= sqrtN && (n = 4*x*x+y*y) <= N; ++x) isprime[n] = !isprime[n]; for(int x = y+1; x <= sqrtN && (n = 3*x*x-y*y) <= N; x += 2) isprime[n] = !isprime[n]; } } for(int z = 2; z <= 4; z += 2){ for(int y = z; y <= sqrtN; y += 6){ for(int x = 1; x <= sqrtN && (n = 3*x*x+y*y) <= N; x += 2) isprime[n] = !isprime[n]; for(int x = y+1; x <= sqrtN && (n = 3*x*x-y*y) <= N; x += 2) isprime[n] = !isprime[n]; } } for(int y = 3; y <= sqrtN; y += 6){ for(int z = 1; z <= 2; ++z){ for(int x = z; x <= sqrtN && (n = 4*x*x+y*y) <= N; x += 3) isprime[n] = !isprime[n]; } } for(int n = 5; n <= sqrtN; ++n) if(isprime[n]) for(int k = n*n; k <= N; k+=n*n) isprime[k] = false; isprime[2] = isprime[3] = true; } u64 ceilk(u64 n, u64 k){ const u64 r = n % k; return r ? n + k - r : n; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); sieve_of_atkin(); u64 L = 1e18 - 1e6, R = 1e18; cin >> L >> R; auto ans = ans_ - L; for(int i = 2; i <= rt; i++) if(isprime[i]){ const u64 p = u64(i) * i; for(u64 i = ceilk(L, p); i <= R; i += p) ans[i] = true; } for(int k = 1; k <= rt2; k++){ int i = sqrt(R / k); if(u64(k) * (i + 1) * (i + 1) <= R) i++; if(u64(k) * i * i >= L) ans[u64(k) * i * i] = true; } cout << count(ans_, ans_ + width, false) << endl; }