let X,K,D = stdin.ReadLine().Split() |> Array.map int64 |> fun input -> abs input.[0],input.[1],input.[2]
if K < X/D then X - K*D 
elif (K-X/D)%2L = 1L then abs (X - X/D * D - D)
else X - X/D * D
|> stdout.WriteLine