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

if x - k*d > 0:
    print(x-k*d)
else:
    v = x // d
    k -= v
    x = x - d*v
    if k % 2 == 0:
        print(x)
    else:
        print(min(abs(x-d), abs(x+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 x - k*d > 0:
    print(x-k*d)
else:
    v = x // d
    k -= v
    x = x - d*v
    if k % 2 == 0:
        print(x)
    else:
        print(min(abs(x-d), abs(x+d))) x - k*d > 0 x - k*d x k*d k d 0 print(x-k*d) print x-k*d x k*d k d v = x // d v x // d x d k -= v k v x = x - d*v x x - d*v x d*v d v if k % 2 == 0:
        print(x)
    else:
        print(min(abs(x-d), abs(x+d))) k % 2 == 0 k % 2 k 2 0 print(x) print x print(min(abs(x-d), abs(x+d))) print min(abs(x-d), abs(x+d)) min abs(x-d) abs x-d x d abs(x+d) abs x+d x d d = map(int, input().split()) map(int, input().split()) d v = x // d x // d v x = abs(x) abs(x) x x, k, d = map(int, input().split()) map(int, input().split()) x k, d = map(int, input().split()) map(int, input().split()) k x = x - d*v x - d*v x k -= v v k
x, k, d = map(int, input().split())
x = abs(x)

if x - k*d > 0:
    print(x-k*d)
else:
    v = x // d
    k -= v
    x = x - d*v
    if k % 2 == 0:
        print(x)
    else:
        print(min(abs(x-d), abs(x+d)))