#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=5000000000000000000;
ll MOD=1000000007;


int main() {
    vector<int> dp(1000001),s(1000001);
    s.at(0)=0;
    queue<int> q;
    q.push(1);
    while (!q.empty()){
        int a=q.front();
        q.pop();
        if (a>1000000) continue;
        dp[a]=1;
        q.push(a*2);
        q.push(a*3);
        q.push(a*5);
    }
    for (int i=1;i<1000001;i++){
        s.at(i)=s.at(i-1)+dp.at(i);
    }
    while (true){
    int t,y;
    cin >> t;
    if (t==0) return 0;
    cin >>y;
    cout << s.at(y)-s.at(t-1) << endl;
}
}

