#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;

const int MX = 1000001;
bool hamming[MX];
int ac[MX];

int main() {
    memset(hamming, 0, sizeof hamming);
    hamming[1] = true;
    ac[0] = 0;
    for (int i=1; i<MX; ++i) {
        if (hamming[i]) {
            if (i*2<MX) hamming[i*2] = true;
            if (i*3<MX) hamming[i*3] = true;
            if (i*5<MX) hamming[i*5] = true;
        }
        ac[i] = ac[i-1] + hamming[i];
    }
    int m, n;
    while (cin >> m, m) {
        cin >> n;
        cout << ac[n] - ac[m-1] << endl;
    }
    return 0;
}