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

if abs(X) > K*D:
    print(abs(X)-K*D)
    sys.exit()
    
for t in range(K):
    # 絶対値の小さい方に移動
    if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
    if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit()

print(abs(temp))
 import sys sys X,K,D= map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D temp = X temp X if abs(X) > K*D:
    print(abs(X)-K*D)
    sys.exit()
     abs(X) > K*D abs(X) abs X K*D K D print(abs(X)-K*D) print abs(X)-K*D abs(X) abs X K*D K D sys.exit() sys.exit sys exit for t in range(K):
    # 絶対値の小さい方に移動
    if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
    if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit() t range(K) range K if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
     abs(temp - D) < abs(temp + D) abs(temp - D) abs temp - D temp D abs(temp + D) abs temp + D temp D temp = temp-D temp temp-D temp D temp = temp+D temp temp+D temp D if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit() abs(temp) < D abs(temp) abs temp D if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit() (K-t-1) % 2 == 0 (K-t-1) % 2 K-t-1 K-t K t 1 2 0 print(abs(temp)) print abs(temp) abs temp sys.exit() sys.exit sys exit if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit() abs(temp - D) < abs(temp + D) abs(temp - D) abs temp - D temp D abs(temp + D) abs temp + D temp D temp = temp-D temp temp-D temp D print(abs(temp)) print abs(temp) abs temp sys.exit() sys.exit sys exit temp = temp+D temp temp+D temp D print(abs(temp)) print abs(temp) abs temp sys.exit() sys.exit sys exit print(abs(temp)) print abs(temp) abs temp X,K,D= map(int,input().split()) map(int,input().split()) X temp = temp+D temp+D temp temp = temp-D temp-D temp D= map(int,input().split()) map(int,input().split()) D temp = X X temp temp = temp-D temp-D temp K,D= map(int,input().split()) map(int,input().split()) K temp = temp+D temp+D temp
import sys
X,K,D= map(int,input().split())
temp = X

if abs(X) > K*D:
    print(abs(X)-K*D)
    sys.exit()
    
for t in range(K):
    # 絶対値の小さい方に移動
    if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
    if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit()

print(abs(temp))

