#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int MAX = 1000000;
    vector<int> hamming(MAX+1, 0);
    hamming[1] = -1;
    for(int i=1; i<=MAX; ++i){
        if(hamming[i] == -1){
            if(i * 2 <= MAX)
                hamming[i*2] = -1;
            if(i * 3 <= MAX)
                hamming[i*3] = -1;
            if(i * 5 <= MAX)
                hamming[i*5] = -1;
            hamming[i] = hamming[i-1] + 1;
        }else{
            hamming[i] = hamming[i-1];
        }
    }

    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        cout << (hamming[n] - hamming[m-1]) << endl;
    }
}