x, k, d = map(int, input().split())
if x < 0:
    x = -x
if k * d <= x:
    print(x - k * d)
else:
    t = x // d
    x -= t * d
    k -= t
    if x >= d:
        x -= d
        k -= 1
    if k % 2 == 1:
        x -= d
    print(abs(x)) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d if x < 0:
    x = -x x < 0 x 0 x = -x x -x x if k * d <= x:
    print(x - k * d)
else:
    t = x // d
    x -= t * d
    k -= t
    if x >= d:
        x -= d
        k -= 1
    if k % 2 == 1:
        x -= d
    print(abs(x)) k * d <= x k * d k d x print(x - k * d) print x - k * d x k * d k d t = x // d t x // d x d x -= t * d x t * d t d k -= t k t if x >= d:
        x -= d
        k -= 1
     x >= d x d x -= d x d k -= 1 k 1 if k % 2 == 1:
        x -= d
     k % 2 == 1 k % 2 k 2 1 x -= d x d print(abs(x)) print abs(x) abs x k -= t t k x -= d d x x -= d d x k, d = map(int, input().split()) map(int, input().split()) k d = map(int, input().split()) map(int, input().split()) d t = x // d x // d t x = -x -x x x -= t * d t * d x k -= 1 1 k x, k, d = map(int, input().split()) map(int, input().split()) x
x, k, d = map(int, input().split())
if x < 0:
    x = -x
if k * d <= x:
    print(x - k * d)
else:
    t = x // d
    x -= t * d
    k -= t
    if x >= d:
        x -= d
        k -= 1
    if k % 2 == 1:
        x -= d
    print(abs(x))
