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

if X < 0:
    X = -X

if X > K * D:
    print(X - K * D)
else:
    count = X // D
    coodinate = X - count * D
    if (K - count) % 2 == 0:
        print(coodinate)
    else:
        print(D - coodinate) X, K, D = list(map(int, input().split())) X list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K D if X < 0:
    X = -X X < 0 X 0 X = -X X -X X if X > K * D:
    print(X - K * D)
else:
    count = X // D
    coodinate = X - count * D
    if (K - count) % 2 == 0:
        print(coodinate)
    else:
        print(D - coodinate) X > K * D X K * D K D print(X - K * D) print X - K * D X K * D K D count = X // D count X // D X D coodinate = X - count * D coodinate X - count * D X count * D count D if (K - count) % 2 == 0:
        print(coodinate)
    else:
        print(D - coodinate) (K - count) % 2 == 0 (K - count) % 2 K - count K count 2 0 print(coodinate) print coodinate print(D - coodinate) print D - coodinate D coodinate X = -X -X X K, D = list(map(int, input().split())) list(map(int, input().split())) K count = X // D X // D count X, K, D = list(map(int, input().split())) list(map(int, input().split())) X D = list(map(int, input().split())) list(map(int, input().split())) D coodinate = X - count * D X - count * D coodinate
X, K, D = list(map(int, input().split()))

if X < 0:
    X = -X

if X > K * D:
    print(X - K * D)
else:
    count = X // D
    coodinate = X - count * D
    if (K - count) % 2 == 0:
        print(coodinate)
    else:
        print(D - coodinate)