import math

value = input().split()
X = int(value[0])
K = int(value[1])
D = int(value[2])

if X != 0:
  if X < 0:
    X = -X
  if K * D <= X:
    print(X - K * D)
  else:
    R = math.ceil(X / D)
    K -= R
    X -= D * R
    if K % 2 == 0:
      print(-X)
    else:
      print(X + D)  
else:
  if K % 2 == 0:
    print("0")
  else:
    print(D) import math math value = input().split() value input().split() ().split () input split X = int(value[0]) X int(value[0]) int value[0] value 0 K = int(value[1]) K int(value[1]) int value[1] value 1 D = int(value[2]) D int(value[2]) int value[2] value 2 if X != 0:
  if X < 0:
    X = -X
  if K * D <= X:
    print(X - K * D)
  else:
    R = math.ceil(X / D)
    K -= R
    X -= D * R
    if K % 2 == 0:
      print(-X)
    else:
      print(X + D)  
else:
  if K % 2 == 0:
    print("0")
  else:
    print(D) X != 0 X 0 if X < 0:
    X = -X
   X < 0 X 0 X = -X X -X X if K * D <= X:
    print(X - K * D)
  else:
    R = math.ceil(X / D)
    K -= R
    X -= D * R
    if K % 2 == 0:
      print(-X)
    else:
      print(X + D)   K * D <= X K * D K D X print(X - K * D) print X - K * D X K * D K D R = math.ceil(X / D) R math.ceil(X / D) math.ceil math ceil X / D X D K -= R K R X -= D * R X D * R D R if K % 2 == 0:
      print(-X)
    else:
      print(X + D)   K % 2 == 0 K % 2 K 2 0 print(-X) print -X X print(X + D) print X + D X D if K % 2 == 0:
    print("0")
  else:
    print(D) K % 2 == 0 K % 2 K 2 0 print("0") print "0" print(D) print D K -= R R K D = int(value[2]) int(value[2]) D X -= D * R D * R X R = math.ceil(X / D) math.ceil(X / D) R X = -X -X X value = input().split() input().split() value X = int(value[0]) int(value[0]) X K = int(value[1]) int(value[1]) K
import math

value = input().split()
X = int(value[0])
K = int(value[1])
D = int(value[2])

if X != 0:
  if X < 0:
    X = -X
  if K * D <= X:
    print(X - K * D)
  else:
    R = math.ceil(X / D)
    K -= R
    X -= D * R
    if K % 2 == 0:
      print(-X)
    else:
      print(X + D)  
else:
  if K % 2 == 0:
    print("0")
  else:
    print(D)