Under construction

Still being built. Things may change

Sum and Product

Time limit2sMemory limit128 MB

Summary
Given a sum S and a product P, find the smallest list of nonnegative reals whose sum is S and product is P, or report -1 if impossible.
Level

Medium6 of 10

Topics
Math, Binary search
Solved
No attempts yet

Problem

Consider a list of nonnegative numbers. If the sum of all numbers in the list is S and their product is P, call the list valid.

Given S and P, find the minimum possible size of a valid list. The size of a list is the number of numbers it contains. If no such list exists, print -1.

The numbers in the list are not required to be integers.

Input

The first line contains two natural numbers S and P, separated by a space. Each number is at most 1,000,000,000.

Output

Print the answer on the first line.

Examples4

  1. Example 1

    Input
    5 6
    
    Expected output
    2
    
  2. Example 2

    Input
    10 10
    
    Expected output
    1
    
  3. Example 3

    Input
    5 100
    
    Expected output
    -1
    
  4. Example 4

    Input
    100 1000000000
    
    Expected output
    9