#include<iostream>
#define D 1000000
using namespace std;
bool flg[D];
int ans[D];
int main(){
	
	int m,n;
	flg[1] = true;
	for(int i = 0;i <= D;i++){
		if(flg[i]){
			if(2*i<=D)flg[2*i] = true;
			if(3*i<=D)flg[3*i] = true;
			if(5*i<=D)flg[5*i] = true;
			//cout<<i<<endl;
		}
	}
	int cnt = 0;
	for(int i = 0;i <= D;i++){
		if(flg[i]) cnt++;
		ans[i] = cnt;
		//cout<<ans[i]<<endl;
	}
	while(cin>>m,m){
		cin>>n;
		cout<<ans[n] - ans[m-1]<<endl;
	}
	


}