defmodule Main do def is_answer(a, b, _) when (a == b), do: false def is_answer(a, _, c) when (a == c), do: false def is_answer(_, b, c) when (b == c), do: false def is_answer(a, b, c) do r1 = rem(a + b, c) r2 = rem(a + c, b) r3 = rem(b + c, a) r1 == 0 && r2 == 0 && r3 == 0 end def solve(a, b) do r = rem(a + b, 2) d2 = div(a + b, 2) cond do is_answer(a, b, a + b) -> (a + b) r == 0 && is_answer(a, b, d2) -> d2 true -> -1 end end def main do [a, b] = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) solve(a, b) |> IO.puts end end