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