import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    let ns = f n
    let p2 = foldl 2 0 ns
    let p5 = foldl 2 0 ns
    print $ min p2 p5


f n | n <= 1 = [1]
    | otherwise = n : f (n - 2)

check x s n | n `mod` x == 0 = s + 1 + check x (n `div` x)
            | otherwise = s