The Last Digit
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given a number N in the decimal numeral system, determine how many numeral systems exist in which the number N ends with the digit k.
Input
The input consists of the number N (0 ≤ N ≤ 10^6) and the digit k (0 ≤ k ≤ 9).
Output
Output a single integer representing the number of numeral systems where the number N ends with the digit k. If there are infinitely many such numeral systems, output "-1".
Examples
Input #1
Answer #1
Submissions 610
Acceptance rate 14%