# walking takahashi

def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D)

if __name__ == "__main__":
  inputs = list(map(int, input().split()))
  print(walk(inputs[0], inputs[1], inputs[2])) def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D) walk abX = abs(X) abX abs(X) abs X if abX >= K*D:
    return abX - K*D
   abX >= K*D abX K*D K D return abX - K*D abX - K*D abX K*D K D itr = round(abX/D) itr round(abX/D) round abX/D abX D ret = K - itr ret K - itr K itr res = abs(abX - D*itr) res abs(abX - D*itr) abs abX - D*itr abX D*itr D itr if (ret % 2) == 0:
    return res
   (ret % 2) == 0 ret % 2 ret 2 0 return res res return abs(res - D) abs(res - D) abs res - D res D X X K K D D if __name__ == "__main__":
  inputs = list(map(int, input().split()))
  print(walk(inputs[0], inputs[1], inputs[2])) __name__ == "__main__" __name__ "__main__" inputs = list(map(int, input().split())) inputs list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split print(walk(inputs[0], inputs[1], inputs[2])) print walk(inputs[0], inputs[1], inputs[2]) walk inputs[0] inputs 0 inputs[1] inputs 1 inputs[2] inputs 2 def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D) def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D) walk inputs = list(map(int, input().split())) list(map(int, input().split())) inputs
# walking takahashi

def walk(X, K, D):
  abX = abs(X)
  if abX >= K*D:
    return abX - K*D
  itr = round(abX/D)
  ret = K - itr
  res = abs(abX - D*itr)
  if (ret % 2) == 0:
    return res
  return abs(res - D)

if __name__ == "__main__":
  inputs = list(map(int, input().split()))
  print(walk(inputs[0], inputs[1], inputs[2]))
