Martian Factorials#2818

Martian Factorials

2 seconds
64 megabytes
Very easy

In the year 3141, a subsequent expedition to Mars uncovered mysterious symbols in one of the caves, providing undeniable evidence of intelligent life on the planet. However, the meaning of these symbols remained a mystery for a long time. Recently, Professor Very-Smart, a leading scientist, made a fascinating discovery: all inscriptions composed of these symbols contain exactly different symbols. Furthermore, each inscription ends with a long sequence of the same symbol.

The professor's conclusion from this observation was astonishing to scientists on Earth. He proposed that these inscriptions represent the factorials of various natural numbers in a numeral system with base . The symbols at the end, he suggested, are zeros—since, as we know, factorials of large numbers end with many zeros. For instance, in our decimal system, factorials start ending with zeros from 5! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120. The number ends with zeros in the decimal system and zeros in a numeral system with base , supporting the professor's hypothesis!

Now, scientists urgently need a program that, given the numbers and , can determine the number of zeros at the end of the representation of N! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot (N-1) \cdot N in the numeral system with base . Your task is to develop such a program to help verify their hypothesis.

Input

The first line of the input file contains the numbers and , separated by a space (1 \leq N \leq 10^{9}, 2 \leq K \leq 1000).

Output

Output the number —the number of zeros at the end of the representation of the number in the numeral system with base .

Examples

Example 1

Loading
Loading