defmodule Main do def main do IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) |> (fn [l,k] -> ceil(l/(2*k) - 1) * k end).() |> IO.puts end end