X, K, D = map(int,input().split())
X = abs(X)
T = X//D
if K < T:
    print(X-K*D)
else:
    X -= T*D
    K -= T
    if K&1:
        print(D-X)
    else:
        print(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 T = X//D T X//D X D if K < T:
    print(X-K*D)
else:
    X -= T*D
    K -= T
    if K&1:
        print(D-X)
    else:
        print(X) K < T K T print(X-K*D) print X-K*D X K*D K D X -= T*D X T*D T D K -= T K T if K&1:
        print(D-X)
    else:
        print(X) K&1 K 1 print(D-X) print D-X D X print(X) print X K -= T T K K, D = map(int,input().split()) map(int,input().split()) K T = X//D X//D T X -= T*D T*D X X, K, D = map(int,input().split()) map(int,input().split()) X X = abs(X) abs(X) X D = map(int,input().split()) map(int,input().split()) D
X, K, D = map(int,input().split())
X = abs(X)
T = X//D
if K < T:
    print(X-K*D)
else:
    X -= T*D
    K -= T
    if K&1:
        print(D-X)
    else:
        print(X)