#C11582. Minimum Operations with Prime Multipliers

    ID: 40914 Type: Default 1000ms 256MiB

Minimum Operations with Prime Multipliers

Minimum Operations with Prime Multipliers

Given two positive integers (a) and (b), determine the minimum number of operations required to transform (a) into (b) by multiplying it by prime numbers. In one operation, you can multiply the current number by any prime number. For example, if (a = 5) and (b = 30), one possible transformation is: (5 \times 2 = 10) and then (10 \times 3 = 30), so the answer is 2. If it is impossible to transform (a) into (b) strictly by such multiplications, output (-1).

inputFormat

The input is provided via standard input. It consists of two positive integers (a) and (b) separated by a space.

outputFormat

Output via standard output a single integer: the minimum number of operations needed to transform (a) into (b) by multiplying by prime numbers, or (-1) if such a transformation is impossible.## sample

5 30
2