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



Sample input:
12


Sample output:
1

Submission status: Accepted

Solution code:
n=int(input())

if n%2==1:
	print(0)
else:
	ans=0
	n=n//2
	while n!=0:
		n=n//5
		ans+=n
	print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=5
b=2
cnt_a=0
cnt_b=0
while a<N:
    cnt_a+=(N//a)//2
    a*=5
while b<N:
    cnt_b+=(N//b)//2
    b*=2
print(0 if N%2==1 else cnt_a)

Submission status: Accepted

Solution code:
N = int(input())
if N%2 == 1:
    print(0)
else:
    ans = 0
    N //= 2
    while N > 0:
        ans += N // 5
        N //= 5
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
c = 0

if n % 2 == 1:
    print(0)
else:
    for i in range(1, 1000):
        c = c + (n // ((5**i)*2))
    print(c)

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])

    if n % 2 != 0:
        return '0'

    ret = 0
    d = 10
    while d <= n:
        ret += n//d
        d *= 5

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:
import math
N = int(input())

if (N % 2) == 1:
  print(0)
  exit()

total = 0

for i in range(1, 2+int(math.log(10**18, 5))):
  t = 5 ** i * 2
  total += N // t

print(total)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

def F(N):
    if N & 1:
        return 0
    N //= 2
    x = 0
    while N:
        N //= 5
        x += N
    return x

answer = F(N)
print(answer)

Submission status: Accepted

Solution code:
N=int(input())
a=5
b=2
cnt_a=0
cnt_b=0
while a<N:
    cnt_a+=(N//a)//2
    a*=5
while b<N:
    cnt_b+=(N//b)//2
    b*=2
print(0 if N%2==1 else min(cnt_a,cnt_b))

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    if N % 2 == 1:
        print(0)
    else:
        ans = 0
        tmp = N // 2
        while tmp != 0:
            tmp //= 5
            ans +=  tmp
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def f(n):
	if n % 2 == 1:
		return 0
	n = n // 2
	ans = 0
	while n:
		n = n // 5
		ans += n
	return ans

if __name__ == "__main__":
	n = int(input())
	print(f(n))

Submission status: Accepted

Solution code:
N = int(input())
l = len(str(N))
if N < 2:
    print(0)
elif N % 2 == 1:
    print(0)
else:
    ans = 0

    for i in range(2*l):
        ans += (N // (10 * (5**i)))
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N&1:
    print(0)
else:
    ans = N//10
    N//=10
    while N>0:
        ans += N//5
        N //=5
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())

l=len(str(n))

q=int(0)
if n%2==1:
    q=0
else:
    for i in range(100):
        if n>(2*(5**(i+1)))-1:
            q +=n//(2*(5**(i+1)))


print(q)

Submission status: Accepted

Solution code:
N = int(input())

def func(n):
  if n < 5:
    return 0
  else:
    nn = int(n // 5)
    return nn + func(nn)

if N % 2 == 1:
  print(0)
else:
  print(func(int(N // 2)))

Submission status: Accepted

Solution code:
import math
N = int(input())

if N%2 != 0:
  answer = 0
else:
  answer = 0
  m = 1
  while int(N//(2*5**m))> 0:
    answer += int(N//(2*5**m))
    m += 1 
print(answer)

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def main():


    n = int(input())
    if n % 2 == 1:
        print(0)
        exit()
    ans = 0
    n//=2
    while n > 0:
        ans += n // 5
        n//=5
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N = int(input())

if N%2 != 0:
  answer = 0
else:
  answer = 0
  m = 1
  while N//(2*5**m) != 0:
    answer += math.floor(N//(2*5**m))
    m += 1 
print(answer)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
x = 10
if n % 2 == 0:
    while x <= n:
        ans += n // x
        x *= 5

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=0
if n%2==0:
    m=10
    while(n>=m):
        s+=n//m
        m*=5
print(s)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
    print(0)
    exit()


n10 = n // 10
ans = n10
tmp = n10
i = 1
while tmp > 0:
    tmp = tmp // 5
    ans += tmp
    i += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2:
    print(0)
    exit()
ans = 0
i = 1
while n >= 2 * 5**i:
    ans += n // (2 * 5**i)
    i += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

if N%2 == 0:
    for i in range(100000000000):
        if 10*(5**i)<=N:
            ans+=N//(10*(5**i))
        else:
            break


print(int(ans))

Submission status: Accepted

Solution code:
import math
N = int(input())

if N%2 != 0:
  answer = 0
else:
  answer = 0
  m = 1
  while math.floor(N)//(2*5**m) > 0:
    answer += math.floor(N//(2*5**m))
    m += 1 
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n % 2 != 0:
    print(0)
    exit()
else:
    ans = 0
    cnt = 10
    while True:
        if n // cnt == 0:
            break
        ans += n // cnt
        cnt = cnt * 5
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
m = 10
if N & 1:
    print(0)
    exit()
while N >= m:
    ans += N//m
    m *= 5
print(ans)

Submission status: Accepted

Solution code:
def run():
  N = int(input())
  if N%2 == 1:
    print(0)
    exit()
  k = 1
  while N > 5**k:
    k += 1
  ans = 0
  for i in range(1, k):
    ans += N//((5**i)*2)
  print(ans)
    
  
if __name__ == '__main__':
  run()

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n%2==0:
    n=n//2
    while n>0:
        n=n//5
        ans+=n
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:print(0);exit()
A=0
add=10
while n>=add:
    A +=n//add
    add *=5
print(A)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    if N & 1:
        return print(0)
    ans = 0
    di = 10
    while di <= N:
        ans += N//di
        di *= 5
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
l = len(str(n))
ans = 0
if n % 2:
  print(0)
  exit()
for i in range(1, 100):
  if i == 1:
    ans += n//10
  ans += n//(10*5**i)
print(ans)

Submission status: Accepted

Solution code:
import math
N = int(input())

a1  = N // 10
a2  = N // 100
a3  = N // 1000
a4  = N // 10000
a5  = N // 100000
a6  = N // 1000000
a7  = N // 10000000
a8  = N // 100000000
a9  = N // 1000000000
a10 = N // 10000000000
a11 = N // 100000000000
a12 = N // 1000000000000
a13 = N // 10000000000000
a14 = N // 100000000000000
a15 = N // 1000000000000000
a16 = N // 10000000000000000
a17 = N // 100000000000000000
a18 = N // 1000000000000000000
a19 = N // 10000000000000000000

b1  = (N // 50) - a2
b2  = (N // 250  ) - a3
b3  = (N // 1250 ) - a4
b4  = (N // ((5**4)*10) ) - a5
b5  = math.ceil(N // ((5**5)*10 )) - a6
b6  = math.ceil(N // ((5**6)*10 )) - a7
b7  = math.ceil(N // ((5**7)*10 )) - a8
b8  = math.ceil(N // ((5**8)*10 )) - a9
b9  = math.ceil(N // ((5**9)*10 )) - a10
b10 = math.ceil(N // ((5**10)*10) ) - a11
b11 = math.ceil(N // ((5**11)*10) ) - a12
b12 = math.ceil(N // ((5**12)*10) ) - a13
b13 = math.ceil(N // ((5**13)*10) ) - a14
b14 = math.ceil(N // ((5**14)*10) ) - a15
b15 = math.ceil(N // ((5**15)*10) ) - a16
b16 = math.ceil(N // ((5**16)*10)) - a17
b17 = math.ceil(N // ((5**17)*10) ) - a18
b18 = math.ceil(N // ((5**18)*10) ) - a19
b19 = math.ceil(N // ((5**19)*10) )
b20 = math.ceil(N // ((5**20)*10) )
b21 = math.ceil(N // ((5**21)*10) )
b22 = math.ceil(N // ((5**22)*10) )
b23 = math.ceil(N // ((5**23)*10) )
b24 = math.ceil(N // ((5**24)*10) )
b25 = math.ceil(N // ((5**25)*10) )
b26 = math.ceil(N // ((5**26)*10) )


ans = a1*1 + a2*1+ a3*1+ a4*1 + a5*1+ a6*1+ a7*1+ a8*1+ a9*1+ a10*1+ a11*1+ a12*1+ a13*1+ a14*1+ a15*1+ a16*1+ a17*1+ a18*1+ a19*1
ans = ans + b1*1 + b2*1+ b3*1+ b4*1 + b5*1+ b6*1+ b7*1+ b8*1+ b9*1+ b10*1+ b11*1+ b12*1+ b13*1+ b14*1+ b15*1+ b16*1+ b17*1+ b18*1 + b19+b20+b21+b22+b23+b24+b25

if N % 2 == 1:
  print(0)
else:
  print(ans)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 0
  div = 5
  while True:
    total += n // (div * 2)
    div *= 5
    if div > n:
      break
  print(total)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
# from bisect import *
# from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
MOD = 10**9+7

N = int(input())
if N % 2:
    print(0)
else:
    ans = 0
    x = 10
    while x <= N:
        ans += N//x
        x *= 5
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
 
five = 5
cnt5 = 0
 
if N % 2 == 1:
    ans = 0
else:
    while True:
        cnt5 += (N // 2) // five
        five *= 5
        if five > N:
            break
print(int(cnt5))

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    
    if N % 2 != 0:
        print(0)
        exit()
    
    ans, denominator = 0, 10
    while denominator <= N:
        ans += N // denominator
        denominator *= 5
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
    print(0)
    exit()

cnt = 0
j = 10
for i in range(25):
    cnt += n // j
    j *= 5
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
if N%2 ==0:
  for i in range(1,30):
    ans += N//((5**i)*2)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
p = 10
su = 0
while p <= n:
   su += n//p
   p*=5

if n%2==1:
    print(0)
else:
    print(su)

Submission status: Accepted

Solution code:
N = int(input())

five = 5
ten = 10
cnt5 = 0
cnt10 = 0

if N % 2 == 1:
    ans = 0
else:
    while True:
        cnt5 += (N // 2) // five
        five *= 5
        if five > N:
            break
    ans = cnt5
print(int(ans))

Submission status: Accepted

Solution code:
from math import factorial
import math
N=int(input())
org=N
b=[]

#Nについて
while N>=5:
  N=N//5
  b.append(N)

ans=0
N=org
if N%2==0:
  for i, item in enumerate(b):
      ans+=item//2
     
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
if n%2==0:
    num=len(str(n))*2
    # n=int(n/2)
    ans=0
    for i in range(num):
        ans+=n//(10*(5**i))
print(int(ans))

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
    exit()
n = n//2
ans = 0
for i in range(1,50):
    ans += (n // (5 ** i))
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

if n%2==1:
    print(0)
    exit()


cntTen=0
temp=1
while 2*5**temp <= n:
    cntTen+=n//(2*5**temp)
    temp+=1



print((int(cntTen)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

def solve(N: int):
    if N%2 == 1:
        print(0)
    else:
        i = 1
        answer  = 0
        while 2*5**i <= N:
            answer += N//(2*5**i)
            i += 1
        print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
n = N // 10
cnt = n
while n >= 5:
    n = n // 5
    cnt += n
print(cnt if N % 2 == 0 else 0)

Submission status: Accepted

Solution code:
"""
Atcoder_Beginner_Contest_148
E - Double Factorial
https://atcoder.jp/contests/abc148/tasks/abc148_e
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000000)

N = int(input())

if N % 2 != 0:
    print(0)
    quit()

zero_count = 0
divide_number = 10
while divide_number <= N:
    zero_count += N // divide_number

    # print("zero_count:{},divide_number:{}".format(zero_count, divide_number))
    divide_number *= 5

print(zero_count)

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
divisor = 10
if N % 2 == 0:
    while N >= divisor:
        ans += N // divisor
        divisor *= 5
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    i = 10
    ans = 0
    while n >= i:
        ans += n // i
        i *= 5
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
    print(0)
    exit()
n//=10
ans=n
while n>0:
    n//=5
    ans+=n
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
l = len(str(N))
if N < 2:
    print(0)
elif N % 2 == 1:
    print(0)
else:
    ans = 0

    for i in range(1, 2*l):
        tmp = 0
        ans += (N // 10**i)
        tmp += (N // (10 * (5**i)))
        tmp -= N // (10 * (10**i))
        ans += max(tmp, 0)

    print(ans)

Submission status: Accepted

Solution code:
n = input()
test = len(n)
n = int(n)
b = 0
if n % 2 == 0:
  for i in range(1,test+11):
    b = b + (n//(5**(i)))//2
print(b)

Submission status: Accepted

Solution code:
def even(n):
    count = 0
    i = 10
    while(n/i>=1):
        count += n//i
        i *= 5
    return int(count) 

def main():
    N = int(input())

    if N < 2:
        print(0)

    # even
    elif N % 2 == 0:
        print(even(N))
    # odd
    elif N % 2 == 1:
        print(0)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
i = int(input())
if i % 2 == 0:
    now = 0
    for j in range(1000):
        now += i // (10 * (5 ** j))
    print(now)
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())
if N%2 ==1 or N ==2:
    print(0)
else:
    half = N//2
    sumone=0
    p=1
    while 5**p <=half:
        sumone += half//(5**p)
        p+=1
    
    print(sumone)

Submission status: Accepted

Solution code:
N = int(input())
answer = 0
number = 5
if N % 2 != 0:
    print(0)
else:
    while number < N:
        answer += N // number // 2 
        number *= 5
    print(answer)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 0:
  ans = 0
  i = 1
  a = None
  while a != ans:
    a = ans
    ans += n // (2*5**i)
    i += 1
else:
  ans = 0
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 != 0:
    print(0)
else:
    count = N // 10
    for j in range(1, 50):
        count += N // ((5**j) * 10)
    print(count)

Submission status: Accepted

Solution code:
from sys import stdin


def solve(N):
    if N % 2 == 1:
        return 0
    if N == 0:
        return 0

    a = N // 50
    b = N // 10

    ans = a + b

    for i in range(2, N):
        x = (5 ** i) * 10
        y = N // x
        if y == 0:
            break
        ans += y

    return ans


def main():
    N = int(stdin.readline().rstrip())
    result = solve(N)
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
    print(0)
    exit()

n = n // 10
ans = n

while n >= 5:
    n //= 5
    ans += n

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
if N % 2 == 1:
    print(0)
    exit()

ans = 0

d = 5
while True:
    if d > N:
        break
    c = N // d
    ans += c // 2
    d *= 5

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)

N = int(input())

#result = f(N)
#print(result)
#
#number = 0
#str_result = list(str(result))
#for s in reversed(str_result):
#    if s == '0':
#        number += 1
#    else:
#        break
#
#print(number)

number = 0
seed = 10
if (N % 2 == 0):
    while seed < 10**18:
        number += N // seed
        seed = seed * 5
        #print((N // 1250) + (N // 250) + (N // 50) + (N // 10))
    print(number)
else:
    print(0)

Submission status: Accepted

Solution code:
import sys
bbn=1000000007
	
#+++++

def ai(n, c):
	if n <= 9550:
		bb=1	
		ret=0
		while n >= 10**bb:
			ret += n // 10**bb
			bb+=1
		return ret+c
	else:
		p=0
		b=n
		while b % 10 == 0:
			p+=1
			b=b//10
		return ai(n-2, c+p)
		
def main():
	n = int(input())
	if n%2==1:
		return 0
	bb=1	
	ret=0
	while n >= 2*(5**bb):
		ret += n // (2*(5**bb))
		bb+=1
	#pa(ai(n,0))
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n % 2 != 0:
    print(ans)
    exit
else:
    n = n // 2
    while (n != 1 and n != 0):
        n = n // 5
        ans += n
    print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

n = int(read())
ans = 0
if n % 2 == 1:
    pass
else:
    cnt = 0
    acc = 5
    while acc <= n:
        cnt += (n // acc) // 2
        acc *= 5
    ans = cnt

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
if (N % 2 == 1):
    print(ans)
else:
    k = N // 2
    i = 1
    while (5**i <= k):
        ans += k//(5**i)
        i += 1
    print(ans)

Submission status: Accepted

Solution code:
#!python3

def resolve():
    N = int(input())

    if N < 2 or (N % 2) == 1:
        print(0)
        return


    n = N // 10
    a = 50
    while a <= N:
        n += N // a
        a *= 5

    print(n)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

#!/usr/bin/env python3

N = int(input().split()[0])

if N % 2 == 0:
    n = (N // 2) // 5
    total_n = n
    count = 2
    while n >= 5:
        p = (N // 2) // (5 ** count)
        total_n += p
        count += 1
        if p <= 0:
            break
        # n_w = n // 5
        # # n_amari = n_w % 5 if n_w % 5 != 0 else 4
        # n_amari = n_w % 5
        # n_f = (n_w - 1) * 5 + (n_amari + 1)
        # # total_n += count * (n_amari + 1)
        # # total_n += (n_amari + 1) + (n_w - 1) * 5
        # n = n // 5
        # count += 1
        # total_n += 1
    ans = total_n
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
import math
n = input()
n = int(n)
summ=0
count = 0
if(n%2==1): print("0")
else:
    while(n/5>0):
        if(count==0): 
            n=str(n)
            n=n[0:len(n)-1]
            if(len(n)==0): break
            else: n=int(n) 
            count+=1
        else:
            n = n*2
            n=str(n)
            n=n[0:len(n)-1]
            if(len(n)==0): break
            else: n=int(n)            
        #print("n="+str(n))
        summ+=n
    print(summ)
#12499999999999996
#1000000000000000000
#100000000000000010
# 99999999999999990

Submission status: Accepted

Solution code:
n = int(input())
if n%2 == 1:
    print(0)
else:
    ans2 = n//10
    c = 50
    while 1:
        if c > n:
            break
        ans2 += n//c
        c = c*5
    print(ans2)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
for i in reversed(range(1,35)):
    ans += n // 5**i //2

if (n % 2 != 0):
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())
Ans=0
if N%2==1:
    Ans=0
else:
    M=N//2
    while M//5!=0:
        t=M//5
        Ans+=t
        M=t
print(Ans)

Submission status: Accepted

Solution code:
def count_2(n):
	d = 2
	c = 1
	while d <= n:
		d *= 2
		c += 1
	
	prev_count = 0
	total_count = 0
	
	while d >= 2:
		count = n // d
#		print(">", d, count, c)
		total_count += (count - prev_count) * c
		prev_count = count
		d //= 2
		c -= 1
	
	return total_count


def count_5(n):
	d = 5
	c = 1
	while d <= n:
		d *= 5
		c += 1
	
	prev_count = 0
	total_count = 0
	
	while d >= 5:
		count = n // d
#		print(">", d, count, c)
		total_count += (count // 2 - prev_count // 2) * c
		prev_count = count
		d //= 5
		c -= 1
	
	return total_count

def count_0(n):
	if n % 2 == 0:
		count2 = count_2(n)
		count5 = count_5(n)
		return min(count2, count5)
	else:
		return 0
print(count_0(int(input())))

Submission status: Accepted

Solution code:
N = int(input())
if N%2==1:
    print(0)
    exit(0)
ans = 0
tmp = N
for i in range(1, 100):
    ans += tmp//pow(5, i)//2
print(ans)

Submission status: Accepted

Solution code:

import sys
N = int(input())
Nby = N // 10
if N % 2 == 1:
    print(0)
    sys.exit(0)

result =  N // 10
for i in range(1, 30):
    result +=  Nby // (5 ** i)

print(result)

Submission status: Accepted

Solution code:
n = int(input())
s = int(list(str(n))[-1])
if n%2 == 1:
    print(0)
else:
    cnt = 0
    for i in range(1, 26):
        cnt += (n - s) // (2*(5**i))
    print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 0:
    result = n // 10
    num = n//10
    while 1 <= num / 5:
        num //= 5
        result += num
    if 5 < num:
        result += 1
    print(result)
else:
    print(0)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)


def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n - 2)


def solve(N):
    result = f(N)
    count = 0
    for x in str(result)[::-1]:
        if x == '0':
            count += 1
        else:
            break
    return count


def solve2(N):
    if N % 2 == 1:
        return 0
    if N == 0:
        return 0

    a = N // 50
    b = N // 10

    ans = a + b

    for i in range(2, 100000000000):
        x = (5 ** i) * 10
        y = N // x
        if y == 0:
            break
        ans += y

    return ans

    # c = N // 250
    # d = N // 1250
    # e = N // 6250
    # return b + a + c + d + e


def main():
    N = int(stdin.readline().rstrip())
    result = solve2(N)
    print(result)

    # result = solve(N)
    # print(result)

    # ans = []
    # for x in range(1, 300):
    #     result = solve(x)
    #     ans.append((x, result))

    # for x in ans:
    #     a, b = x
    #     print(a, b)

    # current = 0
    # count = 0
    # for x in ans:
    #     a, b = x
    #     if a % 2 == 1:
    #         continue
    #     if b == current:
    #         count += 1
    #     elif b == current + 1:
    #         print(current, count)
    #         current = b
    #         count = 0
    #     else:
    #         print(current, count)
    #         print(current + 1, 0)
    #         current = b
    #         count = 0


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
N = int(input())

if N % 2 == 1:
    print(0)
    sys.exit()


count = 0
start = 10
start_lis = []
while start <= N:
    start_lis.append(start)
    start = start // 2
    if int(str(start)[-1]) == 5:
        start *= 10
        
tmp10 = 10
while True:
    count += N // tmp10
    tmp10 *= 10
    if tmp10 > N:
        break

for i in range(1, len(start_lis)):
    tmp = start_lis[i]
    while True:
        count += (N + tmp) // (tmp * 2)
        tmp *= 10
        if tmp > N:
            break

print(count)
#print(*start_lis)

Submission status: Accepted

Solution code:
n = int(input())
if n%2!=0:
    print(0)
else:
    pos = 1
    cnt = 0
    val = (n//(5**pos))//2
    while val!=0:
        cnt+=val
        pos+=1
        val = (n//(5**pos))//2
    print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

chk = False
chk1 = True
bis = 5
ans = 0
if (n % 2 ==1) or (n<10):
    print(0)

else:
    #while chk == False:
    #    if list(str(n))[-1] == "0":
    #        chk = True
    #    else:
    #        n -=2
            
    while n > bis:
        
        ans += n // (bis*2)
        bis = bis *5

        
        
    print(ans)

Submission status: Accepted

Solution code:
n=int(input());print(0 if n%2 else n//10++sum(n//(10*(5**i)) for i in range(1,100)))

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

if N%2==0:
    sums =0
    for i in range(1,26):
        sums += (N//2)//(5**i)
    print(int(sums))
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
  print(0)
  
elif n < 9:
  print(0)
else:
  count = 0
  for i in range(30):
    sub = 10 * (5**i)
    count += n // sub
    
    if sub > n:
      break
      
  print(count)

Submission status: Accepted

Solution code:

N = int(input())

if N%2==1:
    print(0)
else:
    ans = 0
    num = 0
    tmp = N
    while (tmp>49):
        num += tmp//50
        tmp //= 5
    ans += N//10
    ans += num
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n%2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1,30):
        ans += n//(2*(5**i))
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1:
  print(0)
  exit()
def func1(n):
  if n==0:
    return 0
  if n==1:
    return 1
  return 5*func1(n-1)+1
def func(x):
  if x==0:
    return 0
  for i in range(26):
    if x<5**(i+1):
      a=i
      b=x//(5**a)#商
      c=x%(5**a)#あまり
      break
  return b*func1(a)+func(c)
print(func(N//2))

Submission status: Accepted

Solution code:
n=int(input())
if n%2==1:
    print(0)
else:
    print(n//10++sum(n//(10*(5**i)) for i in range(1,100)))

Submission status: Accepted

Solution code:
N=int(input())

if N%2==1:
    print(0)
else:
    f=[0 for _ in range(25)]
    for i in range(25,0,-1):
        f[i-1]=N//(5**i*2)
        o=sum(f)
    print(o)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
    exit()

a = 0
i = 1
while (5**i * 2) <= N:
    a += N // (5**i * 2)
    i += 1

print(a)

Submission status: Accepted

Solution code:
def fac0(a):
    r = 0
    while a > 0:
        r += a//5
        a = a//5
        #print("r=",r)
        #print("a=",a)
    return(r)

N = int(input())
#print("a=",N//2)
#for i in range(999999999999999900,1000000000000000001):
#    N = i
#    print("i=",i)
    
if N % 2 == 0:
    print(fac0(N//2))
else:
    print(0)

Submission status: Accepted

Solution code:
import sys

str = sys.stdin.readline()

N = int(str)

if N % 2 != 0:
    print(0)
else:
    k = 10
    ans = 0
    while k <= N:
        ans += (N - (N % k)) // k
        k = k * 5

    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = [0] * 30
ans = 0
if n % 2 == 1:
    print(0)
else:
    for i in range(30):
        cnt[i] = n // (5 ** (i + 1)) // 2
    print(sum(cnt))

Submission status: Accepted

Solution code:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var):
    print(*var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

n, = I()
if n % 2:
    print(0)
    exit()

n //= 2
ans = 0
for i in range(1, 100):
    ans += n//(5**i)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

if N%2 == 0:
    ans = 0
    for i in range(1, 20):
        ans += (N//(10**i))
    for i in range(1, 40):
        A = (N//((5**i)*(10)))
        B = N//(10**(i+1))
        ans += A - B
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 != 0:
    print(0)
    exit()
count = 0
for i in range(35):
    a = 5 ** i * 10
    b = n // a
    count += b


print(count)

Submission status: Accepted

Solution code:
N = int(input())

if N%2 == 0:
    count = 0
    check = N//2
    n = 5
    while True:
        if check >= n:
            count += check//n
            n *= 5
        else:
            print(count)
            
            break
        
else:
    print(0)

Submission status: Accepted

Solution code:
def f(n):
  if n%2==1: return 0
  else:
    i,m = 1,0
    while n>=5**i:
      m += n//(5**i)//2
      i += 1
    return m

N = int(input())
print(f(N))

Submission status: Accepted

Solution code:
N = int(input())
five = 0
i = 0
if N % 2 == 1:
    print(0)
else:
    while True:
        i += 1
        if 2 * (5 ** i) > N:
            break
        else:
            five += N // (2 * (5**i))
if N %2 != 1:
    print(five)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N=input()

if N%2==1:
    print 0
    quit()

ans=0
N/=10
ans+=N

while 0<N:
    N/=5
    ans+=N
print ans

Submission status: Accepted

Solution code:
N = int(input())

if N%2==1:
  print(0)
else:
  cnt = 0
  NN = (N//10)*10
  for i in range(25):
    cnt += NN//((5**(i+1))*2)
  print(cnt)

Submission status: Accepted

Solution code:
N=int(input())

p=0
q=1
for i in range(N):
  if q*5 <= N:
    q = q*5
    p = p+1
  else:
    break

if N%2==1:
    print(0)
else:
    ans = 0
    for i in range(1,p+1):
        ans = ans + N//(2*(5**i))
    print(ans)

Submission status: Accepted

Solution code:
from math import log
N = int(input())

if (N % 2 != 0) or N == 0: print(0)
else:
    k = N//2
    ans = 0
    for i in range(1,int(log(k,5)+1)):
        ans += k//(5**i)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

if N%2==1:
    print(0)
else:
    count2=0
    count5=0
    n=N

    while(n//2>0):
        count2 += n//2
        n //= 2

    m=N//2

    while(m//5>0):
        count5 += m//5
        m //= 5

    print(min(count2,count5))

Submission status: Accepted

Solution code:
import math 
n = int(input())
p = 0
if n % 2 == 1:
    print(0)
else:
    j = 5
    while j <= n:
        p += n // j // 2
        j *= 5
    print(p)

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
    exit()

res = 0

c = 1
res += N // 10
N //= 10
while N // 5 ** c > 0:
    res += N // 5 ** c
    c += 1
print(res)

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1: #Nが奇数ならどうやっても2を因数に持たない
    print(0)

#関数の出力がほぼ無限に2を因数に持つので、因数にもつ10の個数は5の個数で決まる
else: #2^nごとにn個の5を因数に持つが、偶数縛りなので10*5^nで割った答えを足し合わせれば良い
    ans=0
    i=0
    while N>=10*5**i:
        ans+=N//(10*5**i)
        i+=1
    print(ans)