K. Karamelos at São João
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

João went to the São João festival in Caruaru with a simple mission, at least in his mind: buy sweets for his friends and still keep a little treat for himself to eat after the forró.

João has $$$A$$$ friends and found a stall selling exactly $$$X$$$ different types of sweets. He wants to choose a positive integer $$$Y$$$ and buy exactly $$$Y$$$ sweets of each type. Thus, in total, João would buy $$$X \cdot Y$$$ sweets.

After the purchase, João will distribute the sweets equally among his $$$A$$$ friends, possibly leaving some sweets over. Each friend must receive at least one sweet, because showing up at the party and leaving empty-handed is reason for jokes until the next São João.

To make the count come out exactly as he imagined, exactly one sweet must be left for João himself. Therefore, he wants to know whether there exists some value of $$$Y$$$ that allows this. If it exists, determine the smallest possible one.

Input

The input contains two integers $$$A$$$ and $$$X$$$ ($$$2 \leq A \leq 10^{4}$$$ and $$$1 \leq X \lt A$$$), the number of friends and the number of types of sweets.

Output

Print the smallest possible value of $$$Y$$$, or -1 if it does not exist.

Examples
Input
5 2
Output
3
Input
6 4
Output
-1
Input
7 1
Output
8
Note

Explanation for example 1

With $$$Y = 3$$$, João buys $$$6$$$ sweets: he gives $$$1$$$ sweet to each of his $$$5$$$ friends and keeps the remaining sweet.

Explanation for example 2

The numbers $$$6$$$ and $$$4$$$ have $$$2$$$ as their greatest common divisor. Therefore, every total purchase is a multiple of $$$4$$$, and when divided among $$$6$$$ friends, the remainder is never $$$1$$$. Thus, there is no valid value of $$$Y$$$.

Explanation for example 3

With $$$Y = 1$$$, there would be $$$1$$$ sweet left over, but no friend would receive a sweet. The smallest valid value is $$$Y = 8$$$.