All problems

Problem 866

Preimage Size of Factorial Zeroes Function

Hard · 30 pts · Math, Binary Search

Problem

Let f(x) be the number of trailing zeros of x! (x factorial), which equals floor(x/5) + floor(x/25) + floor(x/125) + .... Given K, count the non-negative integers x with f(x) = K. Since f only increases and stays constant on blocks of five consecutive numbers, the answer is always 0 or 5: binary search for the smallest x with f(x) >= K and check whether f of it equals K.

Input

A single integer K.

Output

Print the number of x with exactly K trailing zeros in x!.

Constraints

0 <= K <= 10^9

Example input

0

Example output

5

Explanation

0!, 1!, 2!, 3! and 4! all have no trailing zeros, so for K = 0 the answer is 5. No factorial has exactly 5 trailing zeros (24! has 4 and 25! has 6), so for K = 5 the answer is 0.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Valid Square Next: Numbers With Repeated Digits