#K61432. Minimum Movements to Target

    ID: 31308 Type: Default 1000ms 256MiB

Minimum Movements to Target

Minimum Movements to Target

A robot is positioned at the origin (0, 0) of a Cartesian plane. The robot needs to reach a target point (tx, ty) by making a sequence of movements. However, the robot can only reach the target if the difference between the x-coordinate and the y-coordinate of the target is even, i.e., if tx - ty \equiv 0 \pmod{2} holds true. If this condition is met, the minimum number of movements required is exactly \max(tx, ty). Otherwise, if the parity condition is not satisfied, the target is unreachable and the answer should be -1.

inputFormat

The input consists of a single line containing two space-separated integers tx and ty (0 ≤ tx, ty ≤ 109), representing the coordinates of the target point.

outputFormat

Output a single integer: the minimum number of movements needed to reach the target if it is reachable; otherwise, output -1.

## sample
3 3
3