#include <iostream>
#include <algorithm>

using namespace std;

bool prime[10000];

void erat()
{

    for (int i = 2; i < 10000; i++) {
        prime[i] = true;
    }

    for (int i = 2; i < 5000; i++) {
        if (prime[i]) {
            for (int j = 2; j*i < 10000; j++) {
                prime[i*j] = false;
            }
        }
    }
}

int main() 
{
    int m, n;
    cin >> m;

    erat();

    while (m) {
        cin >> n;
        int count = 0;

        for (int i = m; i < n+1; i++) {
            bool fl = true;
            for (int j = 7; j*j <= i; j++) {
                if (prime[j] && !(i % j)) {
                    fl = false;
                    break;
                }
            }
            if (fl) {
                count++;
            }
        }
        cout << count << endl;
        cin >> m;
    }
    return 0;
}