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

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

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