#include <iostream>
using namespace std;

int main(){
    while (1) {
        int n,m;
        cin>>n;
        if(n==0)break;
        cin>>m;
        int ans=0;
        for (int i=n; i<=m; i++) {
            if(3600%i==0||21600%i==0||777600000%i==0){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}