import sys

# x = abs(int(input()))
# k = int(input())
# d = int(input())

array = list(map(int, input().strip().split()))
x = abs(array[0])
k = array[1]
d = array[2]
if (d == 0):
    amari = abs(x)

else:
    move_cnt = int(x / d)
    if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

    if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d

print(abs(amari)) import sys sys array = list(map(int, input().strip().split())) array list(map(int, input().strip().split())) list map(int, input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split x = abs(array[0]) x abs(array[0]) abs array[0] array 0 k = array[1] k array[1] array 1 d = array[2] d array[2] array 2 if (d == 0):
    amari = abs(x)

else:
    move_cnt = int(x / d)
    if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

    if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d d == 0 d 0 amari = abs(x) amari abs(x) abs x move_cnt = int(x / d) move_cnt int(x / d) int x / d x d if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

     move_cnt <= k move_cnt k k -= move_cnt k move_cnt amari = x - move_cnt * d amari x - move_cnt * d x move_cnt * d move_cnt d amari = x - k * d amari x - k * d x k * d k d k = 0 k 0 if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d k > 0 k 0 if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d k % 2 == 1 k % 2 k 2 1 if (amari > 0):
                amari -= d
            else:
                amari += d amari > 0 amari 0 amari -= d amari d amari += d amari d print(abs(amari)) print abs(amari) abs amari amari = x - k * d x - k * d amari d = array[2] array[2] d amari = abs(x) abs(x) amari move_cnt = int(x / d) int(x / d) move_cnt amari = x - move_cnt * d x - move_cnt * d amari array = list(map(int, input().strip().split())) list(map(int, input().strip().split())) array amari -= d d amari x = abs(array[0]) abs(array[0]) x k -= move_cnt move_cnt k k = 0 0 k k = array[1] array[1] k amari += d d amari
import sys

# x = abs(int(input()))
# k = int(input())
# d = int(input())

array = list(map(int, input().strip().split()))
x = abs(array[0])
k = array[1]
d = array[2]
if (d == 0):
    amari = abs(x)

else:
    move_cnt = int(x / d)
    if (move_cnt <= k):
        k -= move_cnt
        amari = x - move_cnt * d

    else:
        amari = x - k * d
        k = 0

    if (k > 0):
        if (k % 2 == 1):
            if (amari > 0):
                amari -= d
            else:
                amari += d

print(abs(amari))