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

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

if k * d <= x:
    print(x - k * d)
else:
    k -= x // d
    if k % 2 == 0:
        print(x % d)
    else:
        print(abs(x % d - d))