x,k,d=map(int,input().split())
x=abs(x)
if k>=round(x/d):
  if (k-round(x/d))%2==0:
    print(abs(x-d*round(x/d)))
  else:
    print(d-abs(x-d*round(x/d)))
else:
  print(x-d*k) x,k,d=map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d x=abs(x) x abs(x) abs x if k>=round(x/d):
  if (k-round(x/d))%2==0:
    print(abs(x-d*round(x/d)))
  else:
    print(d-abs(x-d*round(x/d)))
else:
  print(x-d*k) k>=round(x/d) k round(x/d) round x/d x d if (k-round(x/d))%2==0:
    print(abs(x-d*round(x/d)))
  else:
    print(d-abs(x-d*round(x/d))) (k-round(x/d))%2==0 (k-round(x/d))%2 k-round(x/d) k round(x/d) round x/d x d 2 0 print(abs(x-d*round(x/d))) print abs(x-d*round(x/d)) abs x-d*round(x/d) x d*round(x/d) d round(x/d) round x/d x d print(d-abs(x-d*round(x/d))) print d-abs(x-d*round(x/d)) d abs(x-d*round(x/d)) abs x-d*round(x/d) x d*round(x/d) d round(x/d) round x/d x d print(x-d*k) print x-d*k x d*k d k x=abs(x) abs(x) x d=map(int,input().split()) map(int,input().split()) d k,d=map(int,input().split()) map(int,input().split()) k x,k,d=map(int,input().split()) map(int,input().split()) x
x,k,d=map(int,input().split())
x=abs(x)
if k>=round(x/d):
  if (k-round(x/d))%2==0:
    print(abs(x-d*round(x/d)))
  else:
    print(d-abs(x-d*round(x/d)))
else:
  print(x-d*k)