Question
Smallest X Condition

In a kingdom, the ruler gives you two numbers, A and B (where A > B). Your task is to find the smallest number X such that A - B ≤ X ≤ A + B and B - X ≤ X - A. Can you determine the value of X that meets these conditions?

Input
First and the only line of the input contains two space-separated integers A and B.

Constraints
1 ≤ A < B ≤ 109
Output
Find and print the smallest integer X which satisfies the above condition. If no such integer exists, print -1.
Example
Sample Input
8 4
Sample Output
6
Explanation
6 is the smallest integer X between A - B (8 - 4 = 4) and A + B (8 + 4 = 12) such that B - X ≤ X - A.

Online