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

y = abs(X)//D

if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (abs(X)-y*D)
    b = (abs(X)-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000) X,K,D = map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D y = abs(X)//D y abs(X)//D abs(X) abs X D if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (abs(X)-y*D)
    b = (abs(X)-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000) K<=y K y print(abs(abs(X)-K*D)) print abs(abs(X)-K*D) abs abs(X)-K*D abs(X) abs X K*D K D a = (abs(X)-y*D) a abs(X)-y*D abs(X) abs X y*D y D b = (abs(X)-(y+1)*D) b abs(X)-(y+1)*D abs(X) abs X (y+1)*D y+1 y 1 D C = abs(a) C abs(a) abs a D = abs(b) D abs(b) abs b if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000) (K-y)%2==0 (K-y)%2 K-y K y 2 0 print(C) print C print(D) print D X,K,D = map(int,input().split()) map(int,input().split()) X y = abs(X)//D abs(X)//D y a = (abs(X)-y*D) abs(X)-y*D a D = abs(b) abs(b) D C = abs(a) abs(a) C K,D = map(int,input().split()) map(int,input().split()) K D = map(int,input().split()) map(int,input().split()) D b = (abs(X)-(y+1)*D) abs(X)-(y+1)*D b
X,K,D = map(int,input().split())

y = abs(X)//D

if K<=y:
    print(abs(abs(X)-K*D))

else  :
    a = (abs(X)-y*D)
    b = (abs(X)-(y+1)*D)
    
    C = abs(a)
    D = abs(b)
    
    if (K-y)%2==0:
        print(C)
    else:
        print(D)


#print(y+1)
#print(1000000000000000)