#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, m;
const int MAXN = 10000001;
bool simple[MAXN];
for(int i = 2; i <= MAXN; i++){
simple[i] = true;
}
for(int i = 2; i <= sqrt(MAXN); i++){
if(simple[i]){
for(int j = i * i; j <= MAXN; j += i){
simple[j] = false;
}
}
}
int count[MAXN];
int lastSum = 0;
for(int i = 1; i < MAXN; i++){
count[i] = lastSum + simple[i];
lastSum = count[i];
}
while(cin >> m >> n){
int answer = count[n] - count[m] + simple[m];
cout << answer << endl << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKaW50IG1haW4oKQp7CgkgaW50IG4sIG07CQoJIGNvbnN0IGludCBNQVhOID0gMTAwMDAwMDE7CgkgYm9vbCBzaW1wbGVbTUFYTl07CgkgZm9yKGludCBpID0gMjsgaSA8PSBNQVhOOyBpKyspewoJICAgICBzaW1wbGVbaV0gPSB0cnVlOwoJIH0KCSBmb3IoaW50IGkgPSAyOyBpIDw9IHNxcnQoTUFYTik7IGkrKyl7CgkgICAgIGlmKHNpbXBsZVtpXSl7CgkgICAgICAgICBmb3IoaW50IGogPSBpICogaTsgaiA8PSBNQVhOOyBqICs9IGkpewoJICAgICAgICAgICAgIHNpbXBsZVtqXSA9IGZhbHNlOwoJICAgICAgICAgfQoJICAgICB9CgkgfQoKCSBpbnQgY291bnRbTUFYTl07CgkgaW50IGxhc3RTdW0gPSAwOwoJIGZvcihpbnQgaSA9IDE7IGkgPCBNQVhOOyBpKyspewoJICAgICBjb3VudFtpXSA9IGxhc3RTdW0gKyBzaW1wbGVbaV07CgkgICAgIGxhc3RTdW0gPSBjb3VudFtpXTsKCSB9Cgkgd2hpbGUoY2luID4+IG0gPj4gbil7CgkgICAgIGludCBhbnN3ZXIgPSBjb3VudFtuXSAtIGNvdW50W21dICsgc2ltcGxlW21dOwoJICAgICBjb3V0IDw8IGFuc3dlciA8PCBlbmRsIDw8IGVuZGw7CgkgfQp9IA==