이번 문제는 단순 조합 계산을 하면 어려워진다. 마지막 끝자리가 0이 나오는 개수를 새보려고 하면 2와 5의 조합을 생각을 해야하는데 사실상 어렵다. 아래 코드를 보면 좀 이해가 될란지 모르겠다.
n, m = map(int, input().split())
def two_count(n):
two = 0
while n != 0:
n = n // 2
two += n
return two
def five_count(n):
five = 0
while n != 0:
n = n // 5
five += n
return five
print(min(two_count(n) - two_count(n - m) - two_count(m), five_count(n) - five_count(n - m) - five_count(m)))