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

XX = abs(X)

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

XX = abs(X)

if XX > K*D:
    print(XX - K*D)
else:
    if (K - X//D)%2 == 0:
        print(X%D)
    else:
        print(abs(X%D -D))

