X,K,D=map(int,input().split())
a=abs(X)//D
b=abs(X)-a*D
if K<a:
  print(abs(X)-K*D)
else:
  if (K-a)%2==0:
    print(b)
  else:
    print(min(abs(b-D),abs(b+D))) X,K,D=map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D a=abs(X)//D a abs(X)//D abs(X) abs X D b=abs(X)-a*D b abs(X)-a*D abs(X) abs X a*D a D if K<a:
  print(abs(X)-K*D)
else:
  if (K-a)%2==0:
    print(b)
  else:
    print(min(abs(b-D),abs(b+D))) K<a K a print(abs(X)-K*D) print abs(X)-K*D abs(X) abs X K*D K D if (K-a)%2==0:
    print(b)
  else:
    print(min(abs(b-D),abs(b+D))) (K-a)%2==0 (K-a)%2 K-a K a 2 0 print(b) print b print(min(abs(b-D),abs(b+D))) print min(abs(b-D),abs(b+D)) min abs(b-D) abs b-D b D abs(b+D) abs b+D b D K,D=map(int,input().split()) map(int,input().split()) K a=abs(X)//D abs(X)//D a D=map(int,input().split()) map(int,input().split()) D X,K,D=map(int,input().split()) map(int,input().split()) X b=abs(X)-a*D abs(X)-a*D b
X,K,D=map(int,input().split())
a=abs(X)//D
b=abs(X)-a*D
if K<a:
  print(abs(X)-K*D)
else:
  if (K-a)%2==0:
    print(b)
  else:
    print(min(abs(b-D),abs(b+D)))