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())

ans = N // 10

tmp = N // 10
while 5 <= tmp:
    ans += tmp // 5
    tmp = tmp // 5

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	if N % 2:
		print(0)
	else:
		fives = 0
		for i in range(1, 27):
			if N//2 >= 5**i:
				fives += (N//2)//(5**i)
		print(fives)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

out = 0

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

Submission status: Accepted

Solution code:
#E
n=int(input())

if n%2==1:
  print(0)
  exit()
n=((n//10)*10)//2
k=len(str(n))
ans=0
for i in range(1,30):
  ans+=n//(5**i)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
if n%2 != 0:
    print(0)
else:
    nx = (n//10)*10
    
    num = 10
    cnt = 0
    while num <= nx:
        cnt += nx//num
        num *= 5
    print(cnt)

Submission status: Accepted

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from fractions import gcd
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
if n%2 == 1:
    print(0)
    exit()
lis = []
for i in range(1,26):
    lis.append((n // (5**i))//2 )
print(sum(lis))

Submission status: Accepted

Solution code:
def calc(a,n):
    num = 50
    while n >= num:
      a += n//num
      num *= 5
    return a

n = int(input())

if n % 2 == 1:
  print(0)
  exit()
else:
  a = n // 10  
  print(calc(a,n))

Submission status: Accepted

Solution code:
N=int(input())
if N%2:
    print(0)
    exit()
r=0
x=30
y=0
for i in range(30):
    t=N//2//5**x
    r+=(t-y)*x
    x-=1
    y=t
print(r)

Submission status: Accepted

Solution code:
import unittest


class TestE(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(12), 1)

    def test_2(self):
        self.assertEqual(think(5), 0)

    def test_3(self):
        self.assertEqual(think(1000000000000000000), 124999999999999995)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    if n == 0:
        return 0
    if n % 2 == 1:
        return 0
    return count_fives(n // 2)


def write(result):
    print(result)


def count_fives(n):
    count = 0
    mode = 5
    while mode <= n:
        count += n // mode
        mode *= 5
    return count


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys

# print('input >>')
N = int(input())

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

ans = 0
warusu = math.log(N, 5)
warusu = int(warusu)

for i in range(warusu):
    ans += (N // (5 ** (i+1))) // 2

# print('-----output-----')
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

res = 0
if n % 2 == 0:
    m = n // 2
    while m >= 5:
        res += m // 5
        m //= 5

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
num = 10
ans = 0
if N%2 == 0:
    for i in range(10**6):
        if num<=N:
            ans += N//num
            num = num*5
        else:
            print(ans)
            break
else:
    print(0)

Submission status: Accepted

Solution code:
N=int(input())


res=0
for k in range(1,40):
    tmp=N//(5**k)
    if tmp==0:
        break
    #print(tmp)
    res+=(tmp//2)

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

Submission status: Accepted

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

if n==0:
    print(0)

elif n%2==1:
    print(0)
else:
    m = math.floor( math.log(n,5) )
    print( sum(n//(2*5**i) for i in range(1,m+1)) )

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def factorization(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def main():
    N = I()
    n = 5
    ans = 0

    if N % 2 == 0:
        while n <= N:
            ans += N // n // 2
            n *= 5
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

def df(n):
    if n == 0 or n == 1:
        return 0
    elif n % 2 == 1:
        return 0
    else:
        memo = {}
        ans = 0
        def calc(x):
            if x == 0:
                return 0
            if x not in memo:
                memo[x] = calc(x - 1) * 5 + 1
            return memo[x]

        while n >= 50:
            x = n // 2
            c = 0
            while x >= 5:
                x /= 5
                c += 1
            ans += calc(c)
            n -= 5 ** c * 2
        ans += n // 10
        return ans

print(df(N))

Submission status: Accepted

Solution code:
import math
n = int(input())
ans = 0
if n == 0 or n%2 == 1:
  print(0)
  exit()
x = n//2
y = int(math.log(x,5))
for i in range(1,y+1):
  ans += x//5**i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

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

else:
    d = 5
    c = 0
    while d < n:
        c += (n // d) // 2
        d *= 5
    print(c)

Submission status: Accepted

Solution code:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()

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

ans = []
n = N // 10
ans.append(n)

baisuu = 5
while baisuu <= n:
    ans.append(n // baisuu)
    baisuu *= 5

print(sum(ans))

Submission status: Accepted

Solution code:
N = int(input())
d = 2
count = 0
if N % 2 == 1:
    print(0)
else:
    for i in range(N+1):#n回回す　0~n-1まで
        d *= 5
        if d > N:
            break
        count += N//d
    print(count)

Submission status: Accepted

Solution code:
import math

N = int(input())

memo = [0]*26
for i in range(26):
    memo[i] = 5**(i+1)

if N % 2 == 0:
    ans = 0
    for j in range(26):
        ans += (N//memo[j])//2
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
cnt=1
i=1
if n%2==1 or n<10:
  ans=0
else:
  while(n>=5**i):
    #print("cnt",cnt)
    j=5**i
    ans+=(n//j)//2
    i+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

if N%2!=0:
    print(0)
else:
    #M=N/2が5で何回割り切れるかという問題
    M=N//2
    ans=0
    while M>=5:
        M=M//5
        ans+=M
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def Solve(n):
    k = 10
    ans = 0
    while True:
        t = N // k
        if t == 0:
            break
        ans += t
        k *= 5
    return ans

N = int(input())

if N % 2 == 0:
    print(Solve(N))
else:
    print(0)

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())

if N % 2 == 1:
    print(0)
else:
    h = []
    i = 1
    j = 1
    while i != 0:
        i = N // (5**j * 2)
        h += [i]
        j += 1
    s = 0
    for x in h:
        s += x
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

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

else:
    result_2 = 0
    n = N
    while n > 0:
        n //= 2
        result_2 += n

    result_5 = 0
    n = N // 2
    while n > 0:
        n //= 5
        result_5 += n
        
    print(min(result_2, result_5))

Submission status: Accepted

Solution code:
N = int(input())

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

while N % 10 != 0:
    N -= 1

answer = 0

x = 1
while N // (5**x) > 1:
    answer += int((N//(5**x)) // 2)
    x += 1

print(answer)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
if n % 2 == 1:
  ans = 0
else:
  ans += n // 10
  for i in range(1, 25):
    ans += n // (10 * (5 ** i))

print(ans)

Submission status: Accepted

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

l = 1
while(True):
  if pow(5, l) > n:
    break
  if n%2 == 0:
    ans += n//pow(5, l)//2
  l+=1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
m=n
ans=0
for i in range(18):
    ans+=m//10 
    m=m//10
m=n//10   
for i in range(44):
    ans+=m//5
    m=m//5
m=n//10
for i in range(18):
    ans-=m//10 
    m=m//10

if n%2==1: ans=0 
print(int(ans))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()

if N&1:
    print(0)
    exit()

answer = N // 10
x = 50
while N >= x:
    answer += (N // x)
    x *= 5
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
a = 1
na = n
if n % 2 == 1:
    print(0)
else:
    # for i in range(3):
    #     n100 = n // 100
    #     n50 = n // 50
    #     n = n // 10
        
    #     ans += n + n50 - n100
    #     print(n,n50,n100)
    # print(ans)


        # for i in range(1,20):
        #     for j in range(1,40):
        #         ans += (n // ((5**j)*(10**i)))
        #     # ans += (n //(5*10**i))
        # n10 = n // 10
        # print(ans+n10)

    for j in range(1,40):
        ans += (n // ((5**j)*10))
    n10 = n // 10
    print(ans+n10)

# while na != 0:
#     a *= na
#     na -= 2
# # print(a)
# a = list(str(a))
# i = -1
# cnt = 0
# # print(a)
# while a[i] == "0":
#     cnt += 1
#     i -= 1
# print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def count0(n):
    if n % 2 == 1:
        return 0
    
    rst = n // 10
    tmp = rst // 5
    while tmp > 0:
        rst += tmp
        tmp //= 5

    return rst

n = int(input())
print(count0(n))

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    i = 10
    ans = 0
    for _ in range(10 ** 18):
        if n < i:
            break
        ans += n // i
        i *= 5
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N=int(input())
ans=0
temp=0
temp2=0
if N%2==0:
    ans=N//10
    temp=N//10
    for n in range(1,32):
        temp2=5**n
        ans=ans+temp//temp2
print(int(ans))

Submission status: Accepted

Solution code:
N = int(input())

def g(n):
  ans = 0
  for i in range(29):
    ans += n//((5**i)*10)
  return(ans)

if N %2 ==0:
  print(g(N))
else:
  print(0)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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

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

        print(ans)
    else:
        print(0)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def f(n):
    if n%2==1:
        return 0
    ans=0
    i=10
    for j in range(n):
        if n>=i:
            ans+=n//i
            i*=5
        else:
            break
    return ans

n=int(input())
print(f(n))

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 != 0:
  print(0)
else:
  bins = [2 * 5**i for i in range(1, 26)]
  count = 0
  for bin in bins:
    if n < bin:
      break
    else:
      count += n // bin
  print(count)

Submission status: Accepted

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

Submission status: Accepted

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

if n % 2 == 0:
    # n//2の階乗の0の個数
    k = n//2
    cnt = 0
    d = 5
    while True:
        
        cnt += k // d
        if k // d  == 0:
            break
        d *= 5
        
    print(cnt)
    sys.exit()

else:
    k = n //2  + 1 
    
    
    t1 = 0
    t2 = k
    d = 2
    while True:
        t1 += 2*k // d
        if 2*k //d == 0:
            break
        #print(d)
        d *= 2
    
    d = 2
    while True:
        t2 += k // d
        if k //d == 0:
            break
        d *= 2
    
    if t1 == t2:
        print(0)
        sys.exit()
    print(t1, t2)

    

    a = 0
    b = 0
    d = 5
    
    while True:
        
        a += k // d
        if k // d  == 0:
            break
        d *= 5

    d = 5
    while True:
        b += 2*k // d
        if 2*k // d == 0:
            break
        d *= 5
    


    print(b-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
'''

sekai_no_owari
 愛

''' 

def findTrailingZeros(n): 
      
    # Initialize result 
    count = 0
  
    # Keep dividing n by 
    # powers of 5 and 
    # update Count 
    i=10
    while (n/i>0): 
        count += n//i 
        i *= 5
  
    return int(count) 

n = int(input())
if n%2 != 0:
    print(0)
else:
    print(findTrailingZeros(n))

Submission status: Accepted

Solution code:
#e

n = int(input())

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

#n * (n-2) * ... * 3  if n is odd
#n * (n-2) * ... * 2 if n is even
# 2,4,6,8,10,...50,...,250,...,1250
# 10
# 20 * 50
# 40 * 250
# 60 * 500
if n % 2 == 1: ans = 0
else:
    ans = 0
    k = 5
    while 2 * k <= n:
        ans += n // (2 * k)
        k *= 5

print(int(ans))

Submission status: Accepted

Solution code:
N=int(input())
def fact(N,k):
  t=0
  c=0
  while(k**t<N):
    t=t+1
  for i in range(1,t+1):
    c+=N//(k**i)
  return c
if N%2!=0:
  print(0)
else:
  c2=fact(N//2,2)
  c5=fact(N//2,5)
  print(min(c2,c5))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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

    if N == 0 or N == 1:
        ans = 0

    elif N % 2 == 0:
        B = N // 2
        n = math.floor(math.log(B) / math.log(5))

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

    else:
        ans = 0

    print(int(ans))


main()

Submission status: Accepted

Solution code:
import sys

answer=124999999999999995

n = int(input())

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

i=1
j=1
count=0


while 10**i <= n:
  count+= n//(10**i)
  i+=1

while 10*(5**j) <= n:
  count += n//(10*(5**j)) - n//(10**(j+1))
  #print(n//(10*(5**j)) - n//(10**(j+1)))
  j +=1

print(count)
#print(answer-count)

Submission status: Accepted

Solution code:
n = int(input())

def calc(n):
  if n % 2 == 1:
    return 0
  now = 10
  ret = 0
  while now <= n:
    ret += (n//now)
    now *= 5
  return ret
print(calc(n))

Submission status: Accepted

Solution code:
def trail(N):
	if N&1:
		return 0
	cnt=0
	x=1
	while x < N:
		cnt+=(N//(x*10))
		x=5*x
	return cnt
print(trail(int(input())))
# print(trail(400))

Submission status: Accepted

Solution code:

def solve():
    ans=0
    count=0
    if n%2!=0:
        print(0)
    else:
        ini=0
        while count==0:
            ini+=1
            a=n//(5**ini)
        
            if a==0:
                count=-1
            else:
                ans+=a//2
            
        print(ans)

n=int(input())
solve()

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

if N % 2 == 1:
    print(0)
else:
    p = 5
    while p < N:
        n = N // p
        ans += n // 2
        p *= 5

    print(ans)

Submission status: Accepted

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

nums = [10**i for i in range(1,19)]
#fives = [10*5**i for i in range(1,30)]
fives = []
for i in range(1,30):
  for j in range(1,19):
    t = 10**j*5**i
    if t <=n:
      fives.append(t)
a = 0
for i in nums:
  a += n//i
  #print(a,i)

for i in fives:
  a += (1+n//i)//2
  #print(a,i)

print(a)

Submission status: Accepted

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

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())
zero = 0

if n%2 == 1:
  zero = 0

i = n//2
if n%2 == 0:
  while i > 0: 
    i = i//5
    zero += i

print(zero)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
if n % 2 == 0:
    arr = [10 * (5**i) for i in range(1, 25)]
    ans += n // 10
    for i in arr:
        ans += n // i
print(ans)

Submission status: Accepted

Solution code:
import collections

N = int(input())

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

def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

if N % 2 != 0 :
  print(0)
else :
  # result = factorization(N)
  result = 0
  tmp = N//5
  # while True : 
  # tmp = collections.Counter(prime_factorize(N))
  # result += tmp[5]
  while True :
    if tmp == 0 :
      break
    result += (tmp//2)
    tmp = tmp//5
  # print(f(N))
  # cnt = 10
  # result = N//cnt
  # cnt *= 10
  # while True :
    # digit = N//cnt
    # if digit == 0 :
    #   break
    # result += digit
    # tmp = cnt
    # while True :
    #   x = tmp // 2
    #   if x == 0 :
    #     break
    #   result += (N//(x))-(N//tmp)
    #   tmp = x
    # cnt *= 10
  # if N >= 50 :
  #   result += (N//50)-(N//100)
  print(result)
  # print(tmp)

Submission status: Accepted

Solution code:
# ABC148 E
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
import math
n=ni()

if n==0:
    print(0)
    exit()

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

five=math.floor(math.log(n,5))
ans=0

# for i in range(five):
for j in range(five):
    t=n//(5**(five-j))
    ans+=t//2
print(ans)

Submission status: Accepted

Solution code:
#奇数だったら２が約数にない　その後もないので答えは０
#末尾５、０じゃなければ５が約数にない
#2を約数に持つことの方が圧倒的に多いので５を約数に持つときだけ数える、つまり末尾０の時

#2でわって
N=int(input())
count=0

for i in range(1,100000):
  if 5**i<=N//2:
    count+=1
  else:
    break
#print(count)

#//５**iすると


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

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

f = lambda x: x * f(x-2) if x>=2 else 1
# get_odd_even = lambda x: 'even' if x % 2 == 0 else 'odd'

#result = f(N)

#while result % j**e == 0:
#  e+=1
#print(e-1)

cnt = 0
cnt += N//10
#cnt += N//50
#cnt += N//250
#cnt += N//1250
#cnt += N//6250
#cnt += N//31250

j = 50
for e in range(1,25):
  cnt += N//(10*(5**e))

#print(result)
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

if n % 2 == 1:
    ans = 0
else:
    count = 0
    ans = 0
    # for i in range(1, 19):
    #     count = n // (10 ** i)
    #     ans += count
    for j in range(1, 100):
        five = n // (2 * (5 ** j))
        ans += five

    
print(ans)

#124999999999999995
#1000000000000000000
#111111111111111110
#123456790123456788

Submission status: Accepted

Solution code:
N = int(input())

if N % 2 == 1:
    print(0)
else:
    R = 10
    ans = 0
    while True:
        c = (N // R)
        ans += (N // R)
        if c == 0:
            break
        R *= 5

    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
f = 5
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import log10

N = int(input())
if N == 0 or N % 2 == 1: print(0)
else:
    temp = [N // ((5**i) * 2) for i in range(1, 2 * int(log10(N)) + 1)]
    ans = sum(temp)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())  
m=n//2
a=0
if n%2==1:
    a=0
else:
    while m//5>0:
        a=a+m//5
        m=m//5    
    
print("{}".format(a))

Submission status: Accepted

Solution code:
import sys
n=int(input())
if n%2==1:
  print(0)
  sys.exit()
cnt=0
for i in range(1,28):
  cnt+=n//((5**i)*2)
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

b = N // 2
ans = 0
while b:
    tmp = b // 5
    ans += tmp
    b = tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

def f0(N):
    if N < 2:
        return 1
    return N * f0(N-2)

def f(N):
    answer = 1
    n = N
    while n >= 2:
        answer *= n
        n -= 2
    return answer

def test(N):
    b = f(N)
    answer = 0
    while b > 0:
        b, r = divmod(b, 10)
        if r == 0:
            answer += 1
        else:
            break
    return answer

def solve(N):
    M = 10**18
    a = 10
    A = []
    while a <= M:
        A.append(a)
        a *= 5
    #print(len(A))

    if N % 2 == 1:
        return 0
    answer = 0
    for a in A:
        answer += N//a
    return answer

"""
for i in (98, 100, 110, 120, 148, 150, 200, 248, 250, 296, 298, 300, 400, 900, 950, 1000, 5000, 100000):
    t = test(i)
    print(i, t, solve(i), i//10, i//50, i//250, "rem:%d"%(t-(i//10+i//50+i//250+i//(5**3*10))), sep="\t")
"""
N = int(input())
print(solve(N))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    if n%2 != 0:
        print(0)
        return

    if n <= 8:
        print(0)
        return

    ans = 0
    i = 0
    while True:
        x = 10*(5**i)
        if n//x > 0:
            ans += n//x
        else:
            break

        i += 1

    print(ans)

main()

Submission status: Accepted

Solution code:
N = int(input())

a = []
n = 10
while True:
  a.append(n)
  n *= 5
  if n > 10**18:
    break
num = len(a)
numsum = 0
ans = 0
if N % 2 == 1:
  print(0)
else:
  for i, one in enumerate(reversed(a)):
    sho = N // one
    tmp = sho - numsum
    ans += (num - i) * tmp
    numsum += tmp
  print(ans)

Submission status: Accepted

Solution code:
N=int(input())
if N%2==1: #Nが奇数ならどうやっても2を因数に持たない
    print(0)
else: #偶数ならば、10の倍数ごとに5を因数に持つ
    ans=0
    i=1
    ans+=N//10
    while N>=10*5**i:
        ans+=N//(10*5**i)
        i+=1
    print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    if N % 2 == 1 or N == 0:
        print(0)
    else:
        base = 2
        d = 0
        while True:
            base *= 5
            x = N // base
            if x == 0:
                break
            else:
                d += x
        print(d)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

c=0
if N%2!=0:
    pass
else:
    for i in range(26):
        d=5**(i+1)*2
        c+=N//d

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from decimal import Decimal, getcontext
getcontext().prec = 32

N = Decimal(int(input()))

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

ans = Decimal(0)
for i in range(1, 28):
    ans += (N // (Decimal(5) ** Decimal(i))) // Decimal(2)

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b


def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

def f(n):
  if n < 2:
    return 1
  elif n >= 2:
    return n * f(n - 2)


n = INT()
# print@(f(n))

# while n != 1 or n != 2:
#   n = n - 2
#   print(n)

# print(p_l)
# print(two)
# print(five)
# exit()
# a = n // 10
# print(a)
# print(124999999999999995-a)
# b = n // 2
# c = n // 5
# print(b)
# print(c)
a = 5
a_l = []

if n % 2 == 1:
  print(0)
elif n % 2 == 0: # 偶数
# if n == 0:
#   print(1)
# if 
# elif n > 1 and n <= 5:
#   print(0)

# elif n % 2 == 0:
  a = 5
  n = n // 2
  while a <= n:
    a_l.append(a)
    a = a * 5
  # print(a_l[-1])
  # print(a_l)
  ans = 0
  for a in a_l:
    ans += n // a
  
  print(ans)
# elif n % 2 == 1:

Submission status: Accepted

Solution code:
n = int(input())

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

if n < 9:
    print(0)
    exit()

need = n // 10

ans = need
tmp = need
start = 1
"""
while tmp != 0:
    ans += tmp // 10
    tmp = tmp // 10
    #print(tmp)
"""
tmp = need

while tmp != 0:
    ans += tmp // 5
    tmp = tmp // 5

print(ans)