#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
  int m;
  vector<unsigned short> count;
  for(int i=0;i<6;i++)
    count.push_back(i);
  for(int i=6;i<10000001;i++)
    {
      if((i%2==0&&count[i/2]-count[(i/2)-1]!=0) || (i%3==0&&count[i/3]-count[(i/3)-1]!=0) || (i%5==0&&count[i/5]-count[(i/5)-1]!=0))
	  count.push_back(count[i-1]+1);
      else
	count.push_back(count[i-1]);
    }
  for(;cin>>m,m;)
    {
      int n;
      cin>>n;
      cout<<count[n]-count[m-1]<<endl;
    }
}