#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

bool is_hamming[1000010];

void hamming(int n){
	memset(is_hamming,false,sizeof(is_hamming));
	queue<int> q;
	q.push(1);
	while(q.size()){
		int t=q.front(); q.pop();
		is_hamming[t]=true;
		if(2*t<=n) q.push(2*t);
		if(3*t<=n) q.push(3*t);
		if(5*t<=n) q.push(5*t);
	}
	return;
}

int sum[1000010];

signed main(){
	hamming(1000000);
	rep(i,1,1000001){
		sum[i]=sum[i-1];
		if(is_hamming[i]) sum[i]++;
	}
	int n,m;
	while(1){
		cin>>n;
		if(n==0) break;
		cin>>m;
		o(sum[m]-sum[n-1]);
	}
}