line = gets.split(' ').map(&:to_i)

X = line[0]
K = line[1]
D = line[2]

def abs(x)
  if x > 0 then
    return x
  else
    return -x
  end
end
  
def min(x,y)
  if x > y then
    return y
  else
    return x
  end
end
 
X2 = abs(X)
num_to_min = X2 / D
  
if num_to_min >= K then
    puts abs(X2 - K * D)
else
  cand1 = abs(X2 - num_to_min * D)
  cand2 = abs(X2 - (num_to_min + 1) * D)
  if (K - num_to_min) % 2 == 0 then
    puts cand1
  else
    puts cand2
  end
end