countZero :: Integer -> Int
countZero n = length $ takeWhile (==0) [n `mod` (10 ^ i) | i <- [1..]]

main :: IO ()
main = getContents >>= mapM_ (print . f . read) . takeWhile (/="0") . lines
  where f n = countZero $ product [1..n]