x,k,d=map(int,input().split())
x=abs(x)
first_move=x//d
if first_move>k:
  x-=k*d
  x=abs(x)
  print(x)
  exit()

x-=first_move*d
x=abs(x)
k-=first_move
print(abs(x-d) if k&1 else x) 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 first_move=x//d first_move x//d x d if first_move>k:
  x-=k*d
  x=abs(x)
  print(x)
  exit() first_move>k first_move k x-=k*d x k*d k d x=abs(x) x abs(x) abs x print(x) print x exit() exit x-=first_move*d x first_move*d first_move d x=abs(x) x abs(x) abs x k-=first_move k first_move print(abs(x-d) if k&1 else x) print abs(x-d) if k&1 else x k&1 k 1 abs(x-d) abs x-d x d x x=abs(x) abs(x) x first_move=x//d x//d first_move x=abs(x) abs(x) x x,k,d=map(int,input().split()) map(int,input().split()) x x-=k*d k*d x k-=first_move first_move k d=map(int,input().split()) map(int,input().split()) d k,d=map(int,input().split()) map(int,input().split()) k x=abs(x) abs(x) x x-=first_move*d first_move*d x
x,k,d=map(int,input().split())
x=abs(x)
first_move=x//d
if first_move>k:
  x-=k*d
  x=abs(x)
  print(x)
  exit()

x-=first_move*d
x=abs(x)
k-=first_move
print(abs(x-d) if k&1 else x)