X,K,D = map(int,input().split())
X = abs(X)
if K*D>X:
  r = X%D
  K -= (X-r)/D
  if K%2 == 0:
    print(r)
  else:
    print(abs(r-D))
else:
  print(X-(K*D)) 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*D>X:
  r = X%D
  K -= (X-r)/D
  if K%2 == 0:
    print(r)
  else:
    print(abs(r-D))
else:
  print(X-(K*D)) K*D>X K*D K D X r = X%D r X%D X D K -= (X-r)/D K (X-r)/D X-r X r D if K%2 == 0:
    print(r)
  else:
    print(abs(r-D)) K%2 == 0 K%2 K 2 0 print(r) print r print(abs(r-D)) print abs(r-D) abs r-D r D print(X-(K*D)) print X-(K*D) X K*D K D X = abs(X) abs(X) X r = X%D X%D r D = map(int,input().split()) map(int,input().split()) D K,D = map(int,input().split()) map(int,input().split()) K K -= (X-r)/D (X-r)/D 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*D>X:
  r = X%D
  K -= (X-r)/D
  if K%2 == 0:
    print(r)
  else:
    print(abs(r-D))
else:
  print(X-(K*D))