Problem:
Score : 500 points

Problem Statement

For an integer n not less than 0, let us define f(n) as follows:

f(n) = 1 (if n < 2)

f(n) = n f(n-2) (if n \geq 2)

Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Constraints

0 \leq N \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of trailing zeros in the decimal notation of f(N).

Sample Input 1

12

Sample Output 1

1

f(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.

Sample Input 2

5

Sample Output 2

0

f(5) = 5 × 3 × 1 = 15, which has no trailing zeros.

Sample Input 3

1000000000000000000

Sample Output 3

124999999999999995

Solution in Kotlin (1.0.0) (judge verdict: Accepted)

import java.io.*
import java.util.*

fun solve(N: Long) {
    if (N % 2L == 0L) {
        // N = 2m
        // N!! = 2^m * m!
        val m = N / 2
        val ans = Math.min(m + m.powerOfFactorial(2L), m.powerOfFactorial(5L))
        println(ans)
    } else {
        // N = 2m-1
        // N!! = (2m)!/(2^m * m!)
        val m = (N + 1) / 2
        val powOfTwo = (2*m).powerOfFactorial(2L) - m - m.powerOfFactorial(2L)
        val powOfFive = (2*m).powerOfFactorial(5L) - m.powerOfFactorial(5L)
        val ans = Math.min(powOfTwo, powOfFive)
        println(ans)
    }
    return
}

fun Long.powerOfFactorial(base: Long): Long {
    // this! がbaseで何回割り切れるか
    // [this / base] + [this/base*base] + ...
    var count = 0L
    var ret = base
    while (ret <= this) {
        count += (this / ret)
        ret *= base
    }
    return count
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    solve(N)
}