from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))



x,k,d=nii()



dist=abs(x)



num=dist//d



if num>k:

  print((abs(dist-d*k)))

  exit()

else:

  k-=num

  dist1=dist-d*num



  if k>=1:

    dist2=abs(dist1-d)

    if dist2<=dist1:

      k-=1

      dist1=dist2



if k%2==0:

  print(dist1)

else:

  print((min(abs(dist1+d),abs(dist1-d))))
from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))



x,k,d=nii()



dist=abs(x)

num=dist//d



if num>k:

  print((abs(dist-d*k)))

  exit()

else:

  k-=num

  dist-=d*num



if k%2==0:

  print(dist)

else:

  print((min(abs(dist+d),abs(dist-d))))
from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
x, k, d = nii()
dist = abs(x)
num = dist // d
if num > k:
    print((abs(dist - d * k)))
    exit()
else:
    k -= num
    dist1 = dist - d * num
    if k >= 1:
        dist2 = abs(dist1 - d)
        if dist2 <= dist1:
            k -= 1
            dist1 = dist2
if k % 2 == 0:
    print(dist1)
else:
    print((min(abs(dist1 + d), abs(dist1 - d))))

from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
x, k, d = nii()
dist = abs(x)
num = dist // d
if num > k:
    print((abs(dist - d * k)))
    exit()
else:
    k -= num
    dist -= d * num
if k % 2 == 0:
    print(dist)
else:
    print((min(abs(dist + d), abs(dist - d))))

-    dist1 = dist - d * num -    if k >= 1: -        dist2 = abs(dist1 - d) -        if dist2 <= dist1: -            k -= 1 -            dist1 = dist2 +    dist -= d * num -    print(dist1) +    print(dist) -    print((min(abs(dist1 + d), abs(dist1 - d)))) +    print((min(abs(dist + d), abs(dist - d))))