X, K, D = map(int, input().split())
if abs(X) > D * K:
    abso = abs(X) - D * K
    print(abso)
    exit()
div = abs(X)//D
mod = abs(X)%D #+側の最小値
if (K - div)%2 == 0: #K-div:+側での絶対値の最小値までたどり着く回数
    print(mod)
else:
    print(D-mod) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if abs(X) > D * K:
    abso = abs(X) - D * K
    print(abso)
    exit() abs(X) > D * K abs(X) abs X D * K D K abso = abs(X) - D * K abso abs(X) - D * K abs(X) abs X D * K D K print(abso) print abso exit() exit div = abs(X)//D div abs(X)//D abs(X) abs X D mod = abs(X)%D mod abs(X)%D abs(X) abs X D if (K - div)%2 == 0: #K-div:+側での絶対値の最小値までたどり着く回数
    print(mod)
else:
    print(D-mod) (K - div)%2 == 0 (K - div)%2 K - div K div 2 0 print(mod) print mod print(D-mod) print D-mod D mod abso = abs(X) - D * K abs(X) - D * K abso mod = abs(X)%D abs(X)%D mod D = map(int, input().split()) map(int, input().split()) D X, K, D = map(int, input().split()) map(int, input().split()) X K, D = map(int, input().split()) map(int, input().split()) K div = abs(X)//D abs(X)//D div
X, K, D = map(int, input().split())
if abs(X) > D * K:
    abso = abs(X) - D * K
    print(abso)
    exit()
div = abs(X)//D
mod = abs(X)%D #+側の最小値
if (K - div)%2 == 0: #K-div:+側での絶対値の最小値までたどり着く回数
    print(mod)
else:
    print(D-mod)
