410390: GYM104015 H Colored Balls
Description
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).
InputThe 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.
OutputIf Monocarp cannot reach his goal, print $$$-1$$$.
Otherwise, print one integer — the minimum number of operations Monocarp has to perform.
ExamplesInput3 3 1Output
1Input
101 101 101Output
0Input
15 30 20Output
-1Input
12 74 58Output
39Note
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.