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

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

m = min(K, X // D)
X -= D * m
K -= m
if K % 2 == 0:
    print(X)
else:
    print(abs(X - D))
