eolymp
bolt
Try our new interface for solving problems
Problems

Rabbit-failure

Rabbit-failure

On the stop we have N passengers, which Vanja and Peter were among, called at a trolleybus. The Vanja purchased a ticket the first. Peter glanced on the ticket and saw that the number of ticket is a prime number, and decided, that he must purchase a ticket with a simple number. Whether there is a chance at Peter to purchase a ticket to a next stop, if at a conductor only one roll of tickets, in the numbers of tickets is determined the amount by the bought ticket. In case if a roll is closed, Peter will stow "away", and he is expected by a failure.

prb14

Input

An entrance line contains two numbers: amount of passengers and number of trolleybus ticket. The amount of numbers in the number of ticket does not exceed 6.

Output

Show out the amount of passengers, which it is necessary to skip Peter, to purchase a ticket with a simple number, or –1, if doing it is impossible.

Time limit 1 second
Memory limit 64 MiB
Input example #1
5 011
Output example #1
1
Input example #4
6 23
Output example #4
-1