x, k, d = map(int, input().split())

x = abs(x)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-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 straight = min(k, x//d) straight min(k, x//d) min k x//d x d k -= straight k straight x -= straight*d x straight*d straight d if k%2 == 0:
  print(x)
else:
  print(d-x) k%2 == 0 k%2 k 2 0 print(x) print x print(d-x) print d-x d x d = map(int, input().split()) map(int, input().split()) d x -= straight*d straight*d x straight = min(k, x//d) min(k, x//d) straight x = abs(x) abs(x) x k -= straight straight k 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)
straight = min(k, x//d)
k -= straight
x -= straight*d

if k%2 == 0:
  print(x)
else:
  print(d-x)