#!/usr/bin/env ruby

X, K, D = gets.chomp.split.map(&:to_i)

x = X.abs

d, m = x.divmod(D)

r = K - d

case
when r >= 0 && r.even?
  puts m
when r >= 0 && r.odd?
  puts [m - D, m + D].map(&:abs).min
when r < 0
  puts x - (D * K)
end
