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

int main(){
	long long int A,B;
	int n[101][101][3]={};
	while(1){
		cin>>A;if(A==0)break;
		cin>>B;long long int g=60;
		/*
		for(int i=1;i<A;i++){
			g*=60;
			cout<<g<<endl;
		}
		*/

		
		int c=0;
		for(long long int i=A;i<=B;i++){g=60;
		for(long long int j=1;j<11;j++)
		{
			if(g%i==0){//cout<<g<<endl;
	//		cout<<i<<endl;
				c++;break;}
		else{g*=60;}
		}
		}
		cout<<c<<endl;
		
	}
	return 0;
}