main :: IO ()
main = do
  mn <- getLine
  if mn == "0"
    then return ()
    else do
      let [m,n] = map (read :: String -> Int) (words mn)
          ans = (haming' n) - (haming' (m-1))
      putStrLn $ show ans
      main

haming2 :: Int -> Int -> Int
haming2 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming2 (2*x) y) + (haming3 (3*x) y) + (haming5 (5*x) y)

haming3 :: Int -> Int -> Int
haming3 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming3 (3*x) y) + (haming5 (5*x) y)

haming5 :: Int -> Int -> Int
haming5 x y
  | x > y = 0
  | x == y = 1
  | otherwise = 1 + (haming5 (5*x) y)

haming' :: Int -> Int
haming' y = haming2 1 y