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

absX = abs(X)
a = absX - K * D
minX = absX % D

if a > 0:
    print(a)

elif a <= 0:

    Kmin = (absX - minX) / D
    Krem = K - Kmin

    if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D))) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D absX = abs(X) absX abs(X) abs X a = absX - K * D a absX - K * D absX K * D K D minX = absX % D minX absX % D absX D if a > 0:
    print(a)

elif a <= 0:

    Kmin = (absX - minX) / D
    Krem = K - Kmin

    if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D))) a > 0 a 0 print(a) print a elif a <= 0:

    Kmin = (absX - minX) / D
    Krem = K - Kmin

    if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D))) a <= 0 a 0 Kmin = (absX - minX) / D Kmin (absX - minX) / D absX - minX absX minX D Krem = K - Kmin Krem K - Kmin K Kmin if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D))) Krem % 2 == 0 Krem % 2 Krem 2 0 print(min(abs(minX), abs(minX - 2 * D))) print min(abs(minX), abs(minX - 2 * D)) min abs(minX) abs minX abs(minX - 2 * D) abs minX - 2 * D minX 2 * D 2 D print(min(abs(minX + D), abs(minX - D))) print min(abs(minX + D), abs(minX - D)) min abs(minX + D) abs minX + D minX D abs(minX - D) abs minX - D minX D D = map(int, input().split()) map(int, input().split()) D X, K, D = map(int, input().split()) map(int, input().split()) X Krem = K - Kmin K - Kmin Krem minX = absX % D absX % D minX absX = abs(X) abs(X) absX Kmin = (absX - minX) / D (absX - minX) / D Kmin a = absX - K * D absX - K * D a K, D = map(int, input().split()) map(int, input().split()) K
X, K, D = map(int, input().split())

absX = abs(X)
a = absX - K * D
minX = absX % D

if a > 0:
    print(a)

elif a <= 0:

    Kmin = (absX - minX) / D
    Krem = K - Kmin

    if Krem % 2 == 0:
        print(min(abs(minX), abs(minX - 2 * D)))
    else:
        print(min(abs(minX + D), abs(minX - D)))
