import sys









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

x=abs(x)

if(abs(x%d)<abs(x%d-d)):

  min_num=x%d

  min_num2=x%d-d

else:

  min_num=x%d-d

  min_num2=x%d



kaisuu=(x-min_num)/d

if(kaisuu>k):

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

  sys.exit()

if((k%2==0 and kaisuu%2==0)or(k%2==1 and kaisuu%2==1)):

  print((abs(min_num)))

else:

  print((abs(min_num2)))

import math

import sys



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



if x<0:

  x*=-1



num=math.floor(x/d)



if num>k:

  print((x-k*d))

  sys.exit()



n=x-num*d

remaining=k-num



if remaining%2==0:

  if n>0:

    print(n)

    

  else:

    print((n*-1))

    

else:

  if n>0:

    n-=d

    if n>0:

      print(n)

      

    else:

      print((n*-1))

      

  else:

    n+=d

    if n>0:

      print(n)

      

    else:

      print((n*-1))
import sys

x, k, d = list(map(int, input().split()))
x = abs(x)
if abs(x % d) < abs(x % d - d):
    min_num = x % d
    min_num2 = x % d - d
else:
    min_num = x % d - d
    min_num2 = x % d
kaisuu = (x - min_num) / d
if kaisuu > k:
    print((abs(x - d * k)))
    sys.exit()
if (k % 2 == 0 and kaisuu % 2 == 0) or (k % 2 == 1 and kaisuu % 2 == 1):
    print((abs(min_num)))
else:
    print((abs(min_num2)))

import math
import sys

x, k, d = list(map(int, input().split()))
if x < 0:
    x *= -1
num = math.floor(x / d)
if num > k:
    print((x - k * d))
    sys.exit()
n = x - num * d
remaining = k - num
if remaining % 2 == 0:
    if n > 0:
        print(n)
    else:
        print((n * -1))
else:
    if n > 0:
        n -= d
        if n > 0:
            print(n)
        else:
            print((n * -1))
    else:
        n += d
        if n > 0:
            print(n)
        else:
            print((n * -1))

+import math -x = abs(x) -if abs(x % d) < abs(x % d - d): -    min_num = x % d -    min_num2 = x % d - d +if x < 0: +    x *= -1 +num = math.floor(x / d) +if num > k: +    print((x - k * d)) +    sys.exit() +n = x - num * d +remaining = k - num +if remaining % 2 == 0: +    if n > 0: +        print(n) +    else: +        print((n * -1)) -    min_num = x % d - d -    min_num2 = x % d -kaisuu = (x - min_num) / d -if kaisuu > k: -    print((abs(x - d * k))) -    sys.exit() -if (k % 2 == 0 and kaisuu % 2 == 0) or (k % 2 == 1 and kaisuu % 2 == 1): -    print((abs(min_num))) -else: -    print((abs(min_num2))) +    if n > 0: +        n -= d +        if n > 0: +            print(n) +        else: +            print((n * -1)) +    else: +        n += d +        if n > 0: +            print(n) +        else: +            print((n * -1))