#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;

int ham[1000010]={0};
lld sum[1000010]={0};
int num[] = {2,3,5};

void solve(int now){
  if(now > 1000000) return;
  if(ham[now] != 0) return;
  for(int i=0;i<3;i++){
    solve(now*num[i]);
  }
  ham[now] = 1;
  return;
}

int main(){
  solve(1);
  for(int i=1;i<1000001;i++){
    sum[i] = ham[i] + sum[i-1];
  }
  int m,n;
  while(cin >> m , m){
    cin >> n;
    cout << sum[n] - sum[m-1] << endl;
  }
}