let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d %d" @@ fun x k d ->
  let f i = Float.abs @@ float_of_int x +. float_of_int d *. float_of_int (2 * i - k) in
  let i = succ @@ upper_bound (-1) k @@ fun i -> f (i + 1) <= f i in
  Printf.printf "%d\n" @@ abs @@ x + d * (2 * i - k)
