--import Control.Monad


-- helpers
isHammingNum :: Int -> Bool
isHammingNum 1 = True
isHammingNum target
    | mod target 2 == 0     = isHammingNum $ div target 2
    | mod target 3 == 0     = isHammingNum $ div target 3
    | mod target 5 == 0     = isHammingNum $ div target 5
    | otherwise             = False

allHammingNum start end = filter isHammingNum [start .. end]

countHammingNum start end = show $ sum [1 | x <- allHammingNum start end]


-- IO
main = do
    input_ <- getLine
    {-
    when (input_ /= "0") $ do
        let nums = words input_
        putStrLn $ countHammingNum (read (head nums) :: Int) (read (last nums) :: Int)
        main
    -}

    if (input_ == "0")
        then return ()
        else do
            let nums = words input_
            putStrLn $ countHammingNum (read (head nums) :: Int) (read (last nums) :: Int)
            main