require "prime"
arr = [[]]
1.upto(20000){|x| arr << Prime.prime_division(x)}

while true
    n = gets.to_i
    break if n == 0
    h = {2=>0, 5=>0}
    n.downto(2){|x|
        arr[x].each{|prime, beki|
            h[prime] += beki if prime == 2 || prime == 5
            break if prime > 5
        }
    }
    puts h.values.min
end
