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