Factorial
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Factorials of natural numbers N (denoted N!) is the product of all integers from 1 to N, inclusive: N! = 1×2×3×…×N.
Required to determine how many digits "0" end record number N! in K-ary number system.
Input
In the input file contains two numbers: N and K (1 ≤ N ≤ 10^9, 2 ≤ K ≤ 5000). Both numbers are written in decimal notation.
Output
In the output file to bring the number of zeros, which in the K-ary number system ends with the number N!. Number of output in the decimal system.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 29%