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

X = abs(X)

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

X = abs(X)

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