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 PyPy3 (2.4.0) (judge verdict: Wrong Answer)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def valid(tgt):
    # a = nums[tgt]
    a = tgt
    valid = 0
    while (True):
        # print(valid, a)
        if a % 10 == 0:
            valid += 1
            a = a // 10
        else:
            break
    return valid

def main():
    n = input().strip()
    #
    # n = 100
    # nums = [0 for i in range(int(100001))]

    # tmp = 1
    # for i in range(1,50001):
    #     # print(i)
    #     tmp = i * 2 * tmp
    #
    # print("val")

    # print(valid(tmp))
    # for i, num in enumerate(nums[:1001]):
    #     print(str(i) + ":" +str(num))
    # while(True):
    """
    tval = 0
    
    for i in range(5001):

        tgt = i * 2
        valv = valid(nums, tgt)
        if tval != valv:
            print("{} : {}".format(tgt, valv))
            tval = valv
    return
    """

    keta = [0 for i in range(20)]
    keta[1] = 1
    keta[2] = 12
    for i in range(3, 20):
        keta[i] = keta[i-1] * 10 + 4
        if i > 3:
            keta[i] += 5

    print(keta)
    ans = 0
    if int(n[-1]) % 2 == 1:
        print(0)
        return

    else:
        prev = ""
        pprev = ""
        for i, digit in enumerate(n[::-1]):
            ans += int(digit) * keta[i]
            if i == 1:
                bonus = int(digit) // 5
            elif i == 2:
                bonus = int(digit + prev) // 25
            else:
                bonus = int(digit + prev + pprev) // 125
                if int(digit + prev + pprev) >= 625:
                    bonus += 1
            ans += bonus
            prev = digit
            pprev = prev

        print(ans)



if __name__ == "__main__":
    main()

"""
1000
124
2000
249
3000
374
4000
499
5000
624
6000
748
8000
999
9000
1124
10000
1249

"""