e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

DSLCS 2011 Number Theory. Favorites

Sum And Product

A list of non-negative numbers is called satisfactory if the sum of the numbers in the list is equal to s and the product of the numbers is equal to p. Find a satisfactory list with the least possible number of elements.

Input

Each line is a separate test that contains two non-negative integers s and p (1s, p109).

Output

For each test case print in a separate line the size of satisfactory list with the least possible number of elements. If no such list exists, print -1 instead. Please note that the list may contain non-integer numbers.

Time limit 1 second
Memory limit 128 MiB
Input example #1
10 10
5 6
5 100
Output example #1
1
2
-1