X,K,D=list(map(int,input().split()))
X=abs(X)
import sys

if X > 0 and X-K*D>=0:
    print(X-K*D)
    sys.exit()

M=X//D
Q=X%D

if M%2 == K%2:
    print(Q)
else:
    print(D-Q)
 X,K,D=list(map(int,input().split())) X list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K D X=abs(X) X abs(X) abs X import sys sys if X > 0 and X-K*D>=0:
    print(X-K*D)
    sys.exit() X > 0 and X-K*D>=0 X > 0 X 0 X-K*D>=0 X-K*D X K*D K D 0 print(X-K*D) print X-K*D X K*D K D sys.exit() sys.exit sys exit M=X//D M X//D X D Q=X%D Q X%D X D if M%2 == K%2:
    print(Q)
else:
    print(D-Q) M%2 == K%2 M%2 M 2 K%2 K 2 print(Q) print Q print(D-Q) print D-Q D Q M=X//D X//D M Q=X%D X%D Q D=list(map(int,input().split())) list(map(int,input().split())) D X,K,D=list(map(int,input().split())) list(map(int,input().split())) X X=abs(X) abs(X) X K,D=list(map(int,input().split())) list(map(int,input().split())) K
X,K,D=list(map(int,input().split()))
X=abs(X)
import sys

if X > 0 and X-K*D>=0:
    print(X-K*D)
    sys.exit()

M=X//D
Q=X%D

if M%2 == K%2:
    print(Q)
else:
    print(D-Q)

