import Control.Monad
import Control.Applicative
import System.Exit (exitSuccess)
main = do
  nums <- map read <$> lines <$> getContents
  forM_ nums $ \i -> do
    if i == 0 then exitSuccess else do
      let t = sum [two | j <- [2..i], let two = div' j 2]
      let f = sum [five | j <- [2..i], let five = div' j 5]
      print $ min t f

div' 0 m = 0
div' n m
  | mod n m == 0 = 1 + div' (div n m) m
  | otherwise = 0
