D. Snake
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Andrey fills a table in a «snake» pattern: in the first row, he writes numbers in increasing order from left to right, starting with 1, then he continues in the second row from right to left, then in the third row — again from left to right, and so on. In this table, a 2 x 2 fragment was found with the numbers

a+1a
bb+1

Determine the maximum number of columns that could have been in Andrey's table.

Input

Two integers $$$a$$$ and $$$b$$$ are given, each on a separate line ($$$1 \le a, b \le 10^9$$$).

Output

Output a single integer — the answer. If there is no solution, output -1.

Scoring

Solutions that work correctly for $$$a, b \le 1000$$$ will score at least 30 points.

Solutions that work correctly for $$$a, b \le 10^6$$$ will score at least 60 points.

Example
Input
4
8
Output
3
Note

The table in the example looks like this:

123
654
789