main = interact $ unlines . map (show . factorial2 . read) . (takeWhile (/="0")) . lines
factorial2 n = sum $ takeWhile (/= 0) $ map (\x -> length $ takeWhile (<= n) $ iterate (+x) x) $ iterate (*5) 5