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