- Time limit: 1.00 s
- Memory limit: 512 MB
You are given two numbers: and . Your task is to find such that and or report that such number doesn't exist.
Input
The only line consists of the numbers and .
Output
The output consists of one integer: if it exists or -1 if such doesn't exist.
Constraints
Example
Input:
3 5
Output:
2
Explanation:
Input:
4 6
Output:
-1
Explanation: is either 0, 2 or 4 modulo 6 for any .