#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	
int x,y,c=0;
bool f[1000001];

for(int i=0;i<1000001;i++)
{f[i]=false;}

for(int i=1;i<=1000001;i++)
{
if(i%2==0)f[i]=true;
else if(i%3==0)f[i]=true;
else if(i%5==0)f[i]=true;
}

while
	(1)
	//(scanf("%d",&x)!=0)
{
	scanf("%d",&x);
	if(x==0)break;
//cin>>y;
	scanf("%d",&y);
	
	
	for(int i=x;i<=y;i++)
{if(f[i]==true)c++;
	}
	
	
	/*
for(int i=x;i<=y;i++)
{
if(i%2==0)c++;
else if(i%3==0)c++;
else if(i%5==0)c++;
}
*/
printf("%d\n",c);c=0;
}
return 0;
}