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

N = abs(X) // D
O = abs(X) - N * D

if O <= (D - O):
    pass
else:
    N += 1
    O = D - O
    
if N >= K:
    print(abs(X) - K * D)
else:
    if (K - N) % 2 == 0:
        print (O)
    else:
        print(D - O) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D N = abs(X) // D N abs(X) // D abs(X) abs X D O = abs(X) - N * D O abs(X) - N * D abs(X) abs X N * D N D if O <= (D - O):
    pass
else:
    N += 1
    O = D - O
     O <= (D - O) O D - O D O N += 1 N 1 O = D - O O D - O D O if N >= K:
    print(abs(X) - K * D)
else:
    if (K - N) % 2 == 0:
        print (O)
    else:
        print(D - O) N >= K N K print(abs(X) - K * D) print abs(X) - K * D abs(X) abs X K * D K D if (K - N) % 2 == 0:
        print (O)
    else:
        print(D - O) (K - N) % 2 == 0 (K - N) % 2 K - N K N 2 0 print (O) print O print(D - O) print D - O D O N += 1 1 N K, D = map(int, input().split()) map(int, input().split()) K O = D - O D - O O D = map(int, input().split()) map(int, input().split()) D N = abs(X) // D abs(X) // D N X, K, D = map(int, input().split()) map(int, input().split()) X O = abs(X) - N * D abs(X) - N * D O
X, K, D = map(int, input().split())

N = abs(X) // D
O = abs(X) - N * D

if O <= (D - O):
    pass
else:
    N += 1
    O = D - O
    
if N >= K:
    print(abs(X) - K * D)
else:
    if (K - N) % 2 == 0:
        print (O)
    else:
        print(D - O)