#!/usr/bin/ruby

X, K, D = $stdin.gets.split.map {|i| i.to_i }

def calc
  if X == 0
    return 0
  end
  xabs = X.abs
  k = xabs / D
  case
  when K <= k
    return xabs - D * K
  else
    dk = K - k
    if dk % 2 == 0
      return xabs - D * k
    else
      return D * (k + 1) - xabs
    end
  end
end

puts calc
