410390: GYM104015 H Colored Balls

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Colored Ballstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp has got several colored balls — $$$a$$$ red ones, $$$b$$$ green ones and $$$c$$$ blue ones.

Monocarp can transform the balls as follows: he can take two balls of different colors and merge them into a ball of the third color (two balls he has taken disappear, and a new ball of the third color appears). For example, Monocarp can merge a red ball and a blue ball into a green ball.

Monocarp wants to perform several (maybe zero) operations in such a way that, after performing them, the number of balls of each color is the same for all colors. Your task is to calculate if it is possible, and determine the minimum number of operations Monocarp has to perform to reach his goal (if he can do it at all).

Input

The first line contains three integers $$$a$$$, $$$b$$$ and $$$c$$$ ($$$0 \le a, b, c \le 10^{9}; a + b + c > 0$$$) — the number of red, green and blue balls Monocarp has.

Output

If Monocarp cannot reach his goal, print $$$-1$$$.

Otherwise, print one integer — the minimum number of operations Monocarp has to perform.

ExamplesInput
3 3 1
Output
1
Input
101 101 101
Output
0
Input
15 30 20
Output
-1
Input
12 74 58
Output
39
Note

In the first example, Monocarp can merge a red ball and a green ball to get a blue ball. Then he will have two balls for each color.

In the second example, Monocarp doesn't have to perform any operations.

In the third example, it's impossible to achieve Monocarp's goal.

加入题单

算法标签: