import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  auto dp = new bool[](3000001);
  dp[1] = 1;
  foreach (i; 1..500001) {
    if (dp[i]) {
      dp[i*2] = dp[i*3] = dp[i*5] = 1;
    }
  }
  foreach (line; stdin.byLine) {
    auto x = line.chomp.split.map!(to!int);
    if (x.length == 1) break;
    int cnt;
    foreach (i; x[0]..x[1]+1) {
      if (dp[i]) cnt++;
    }
    cnt.writeln;
  }
}