#K75847. Minimum Operations to Prime

    ID: 34510 Type: Default 1000ms 256MiB

Minimum Operations to Prime

Minimum Operations to Prime

You are given two positive integers s and t. Your task is to transform s into a prime number that is greater than or equal to t using the minimum number of operations. The allowed operations are:

  • Add 1
  • Subtract 1
  • Multiply by 2

You must output the minimum number of operations required. It is guaranteed that a solution exists for all inputs.

Note: A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. The transformation should always yield a positive number.

inputFormat

The input consists of two space-separated integers s and t provided via standard input.

Constraints: Both s and t are positive integers.

outputFormat

Output a single integer representing the minimum number of operations required to transform s into a prime number that is greater than or equal to t.

## sample
10 20
3

</p>