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