#include #define HASH 1000003 const int H_Mod = HASH; typedef struct List { struct List *next; long long v, ans; } list; // N <= 10^11 long long prime_count(long long N) { if (N <= 1) return 0; int h, k; long long i, ii, key[1000000], tmp; list *hash[HASH] = {}, d[1000000], *p, *pp; for (i = 1, k = 0; i * i <= N; i++) { key[k] = N / i; d[k].v = key[k]; d[k].ans = key[k] - 1; h = key[k] % H_Mod; d[k].next = hash[h]; hash[h] = &(d[k++]); } for (i = d[k-1].v - 1; i > 0; i--) { key[k] = i; d[k].v = i; d[k].ans = i - 1; d[k].next = hash[i]; hash[i] = &(d[k++]); } for (i = 2; i * i <= N; i++) { for (p = hash[i]; p != NULL; p = p->next) if (p->v == i) break; for (pp = hash[i-1]; pp != NULL; pp = pp->next) if (pp->v == i - 1) break; if (p->ans <= pp->ans) continue; for (k = 0, ii = i * i; key[k] >= ii; k++) { tmp = key[k] / i; h = tmp % H_Mod; for (p = hash[h]; p != NULL; p = p->next) if (p->v == tmp) break; d[k].ans -= p->ans - pp->ans; } } return d[0].ans; } int main() { long long L, R; scanf("%lld %lld", &L, &R); printf("%lld\n", prime_count(R) - prime_count(L - 1) + prime_count(R * 2 - 1) - prime_count(L * 2)); fflush(stdout); return 0; }