import sys
X, K, D = map(int, input().split())
X = abs(X)
if X//D  > K:
    print(X-D*K)
    sys.exit()
K -= X//D
X %= D
if K%2 == 0:
    print(X)
else:
    print(D-X) import sys sys 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 X//D  > K:
    print(X-D*K)
    sys.exit() X//D  > K X//D X D K print(X-D*K) print X-D*K X D*K D K sys.exit() sys.exit sys exit 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 %= D D X X, K, D = map(int, input().split()) map(int, input().split()) X D = map(int, input().split()) map(int, input().split()) D K, D = map(int, input().split()) map(int, input().split()) K X = abs(X) abs(X) X
import sys
X, K, D = map(int, input().split())
X = abs(X)
if X//D  > K:
    print(X-D*K)
    sys.exit()
K -= X//D
X %= D
if K%2 == 0:
    print(X)
else:
    print(D-X)