Trailing Loves (or L'oeufs?)
Hazrat Ali
Aki is fond of numbers, especially those with trailing zeros. For example, the number 9200 has two trailing zeros. Aki thinks the more trailing zero digits a number has, the prettier it is.
However, Aki believes, that the number of trailing zeros of a number is not static, but depends on the base (radix) it is represented in. Thus, he considers a few scenarios with some numbers and bases. And now, since the numbers he used become quite bizarre, he asks you to help him to calculate the beauty of these numbers.
Given two integers nn and bb (in decimal notation), your task is to calculate the number of trailing zero digits in the bb-ary (in the base/radix of b) representation of n! (factorial of n).
The only line of the input contains two integers nn and b (1≤n≤10).
Print an only integer the number of trailing zero digits in the bb-ary representation of n!n!
6 9
1
38 11
3
5 2
3
5 10
1
Solution