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