x,k,d = list(map(int, input().split()))
amari = abs(x) % d
shou = abs(x) // d

amari_ = abs(amari - d)
if k < shou:
  print(abs(x) - d * k)
else:
  if (k - shou) % 2 == 0:
    print(amari)
  else:
    print(amari_) x,k,d = list(map(int, input().split())) x list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k d amari = abs(x) % d amari abs(x) % d abs(x) abs x d shou = abs(x) // d shou abs(x) // d abs(x) abs x d amari_ = abs(amari - d) amari_ abs(amari - d) abs amari - d amari d if k < shou:
  print(abs(x) - d * k)
else:
  if (k - shou) % 2 == 0:
    print(amari)
  else:
    print(amari_) k < shou k shou print(abs(x) - d * k) print abs(x) - d * k abs(x) abs x d * k d k if (k - shou) % 2 == 0:
    print(amari)
  else:
    print(amari_) (k - shou) % 2 == 0 (k - shou) % 2 k - shou k shou 2 0 print(amari) print amari print(amari_) print amari_ amari = abs(x) % d abs(x) % d amari x,k,d = list(map(int, input().split())) list(map(int, input().split())) x shou = abs(x) // d abs(x) // d shou d = list(map(int, input().split())) list(map(int, input().split())) d amari_ = abs(amari - d) abs(amari - d) amari_ k,d = list(map(int, input().split())) list(map(int, input().split())) k
x,k,d = list(map(int, input().split()))
amari = abs(x) % d
shou = abs(x) // d

amari_ = abs(amari - d)
if k < shou:
  print(abs(x) - d * k)
else:
  if (k - shou) % 2 == 0:
    print(amari)
  else:
    print(amari_)