#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

#define rep(i, n) for(int i = 0;i < n;i++)

const int N = 1000001;
int hamming[N];

int main() {
    rep(i, N) hamming[i] = true;

    hamming[0] = false;
    rep(i, N) {
        if(!hamming[i]) continue;
        if(i == 1 || i % 2 == 0 || i % 3 == 0 || i % 5 == 0) continue;

        for(int j = i * 1; j < N;j += i) {
            hamming[j] = false;
        }
    }

    //rep(i, 50) printf("%d %d\n", i, hamming[i]);

    while(1) {
        int m, n;
        cin >> m;
        if(!m) break;
        cin >> n;

        int ans = 0;
        for(int i = m;i <= n;i++) {
            if(hamming[i]) ans++;
        }
        cout << ans << endl;
    }

    return 0;
}