import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

    X,K,D=map(int,input().split())

    ans=0
    if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

    print(ans)
resolve() import math math import collections collections import itertools itertools def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return YesNo if(Bool):
        print("Yes")
    else:
        print("No")
     Bool print("Yes") print "Yes" print("No") print "No" return Bool Bool def resolve():

    X,K,D=map(int,input().split())

    ans=0
    if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

    print(ans) resolve X,K,D=map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D ans=0 ans 0 if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

     abs(X)-K*D<0 abs(X)-K*D abs(X) abs X K*D K D 0 tmp=X//D tmp X//D X D if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
     (K-tmp)%2==0 (K-tmp)%2 K-tmp K tmp 2 0 ans=abs(X-D*tmp) ans abs(X-D*tmp) abs X-D*tmp X D*tmp D tmp ans=abs(X-D*(tmp+1)) ans abs(X-D*(tmp+1)) abs X-D*(tmp+1) X D*(tmp+1) D tmp+1 tmp 1 ans=abs(X)-K*D ans abs(X)-K*D abs(X) abs X K*D K D print(ans) print ans resolve() resolve def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return YesNo def resolve():

    X,K,D=map(int,input().split())

    ans=0
    if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

    print(ans) def resolve():

    X,K,D=map(int,input().split())

    ans=0
    if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

    print(ans) resolve
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

    X,K,D=map(int,input().split())

    ans=0
    if(abs(X)-K*D<0):
        tmp=X//D
        if((K-tmp)%2==0):
            ans=abs(X-D*tmp)
        else:
            ans=abs(X-D*(tmp+1))
    else:
        ans=abs(X)-K*D

    print(ans)
resolve()
