n,k,d=map(int,input().split())
n=abs(n)
q=n//d
r=n%d
if(k<=q):
    print(n-k*d)
else:
    rem=k-q
    if(rem%2==0):
        print(r)
    else:
        print(min(abs(r-d),abs(r+d))) n,k,d=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k d n=abs(n) n abs(n) abs n q=n//d q n//d n d r=n%d r n%d n d if(k<=q):
    print(n-k*d)
else:
    rem=k-q
    if(rem%2==0):
        print(r)
    else:
        print(min(abs(r-d),abs(r+d))) k<=q k q print(n-k*d) print n-k*d n k*d k d rem=k-q rem k-q k q if(rem%2==0):
        print(r)
    else:
        print(min(abs(r-d),abs(r+d))) rem%2==0 rem%2 rem 2 0 print(r) print r print(min(abs(r-d),abs(r+d))) print min(abs(r-d),abs(r+d)) min abs(r-d) abs r-d r d abs(r+d) abs r+d r d rem=k-q k-q rem k,d=map(int,input().split()) map(int,input().split()) k n,k,d=map(int,input().split()) map(int,input().split()) n d=map(int,input().split()) map(int,input().split()) d r=n%d n%d r n=abs(n) abs(n) n q=n//d n//d q
n,k,d=map(int,input().split())
n=abs(n)
q=n//d
r=n%d
if(k<=q):
    print(n-k*d)
else:
    rem=k-q
    if(rem%2==0):
        print(r)
    else:
        print(min(abs(r-d),abs(r+d)))