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