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

X = abs(X)

if K * D < X:
    print(X - K * D)

else:
    cnt = (X - X%D) // D
    if (K-cnt)%2==0:
        print(X%D)
    else:
        print(D - 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 * D < X:
    print(X - K * D)

else:
    cnt = (X - X%D) // D
    if (K-cnt)%2==0:
        print(X%D)
    else:
        print(D - X%D) K * D < X K * D K D X print(X - K * D) print X - K * D X K * D K D cnt = (X - X%D) // D cnt (X - X%D) // D X - X%D X X%D X D D if (K-cnt)%2==0:
        print(X%D)
    else:
        print(D - X%D) (K-cnt)%2==0 (K-cnt)%2 K-cnt K cnt 2 0 print(X%D) print X%D X D print(D - X%D) print D - X%D D X%D X D X = abs(X) abs(X) X K, D = map(int, input().split()) map(int, input().split()) K D = map(int, input().split()) map(int, input().split()) D cnt = (X - X%D) // D (X - X%D) // D cnt X, K, D = map(int, input().split()) map(int, input().split()) X
X, K, D = map(int, input().split())

X = abs(X)

if K * D < X:
    print(X - K * D)

else:
    cnt = (X - X%D) // D
    if (K-cnt)%2==0:
        print(X%D)
    else:
        print(D - X%D)
