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