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

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

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