X,K,D = list(map(int,input().split()))
max_number = X + K*D
min_number = X - K*D
if min_number >= 0:
    ans = min_number
elif max_number <= 0:
    ans = -max_number
else:
    q = max_number // (2*D)
    ans1 = max_number - 2*q*D
    ans2 = max_number - 2*(q+1)*D
    if ans1 > -ans2:
        ans = -ans2
    else:
        ans = ans1
print(ans) 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 max_number = X + K*D max_number X + K*D X K*D K D min_number = X - K*D min_number X - K*D X K*D K D if min_number >= 0:
    ans = min_number
elif max_number <= 0:
    ans = -max_number
else:
    q = max_number // (2*D)
    ans1 = max_number - 2*q*D
    ans2 = max_number - 2*(q+1)*D
    if ans1 > -ans2:
        ans = -ans2
    else:
        ans = ans1 min_number >= 0 min_number 0 ans = min_number ans min_number elif max_number <= 0:
    ans = -max_number max_number <= 0 max_number 0 ans = -max_number ans -max_number max_number q = max_number // (2*D) q max_number // (2*D) max_number 2*D 2 D ans1 = max_number - 2*q*D ans1 max_number - 2*q*D max_number 2*q*D 2*q 2 q D ans2 = max_number - 2*(q+1)*D ans2 max_number - 2*(q+1)*D max_number 2*(q+1)*D 2*(q+1) 2 q+1 q 1 D if ans1 > -ans2:
        ans = -ans2
    else:
        ans = ans1 ans1 > -ans2 ans1 -ans2 ans2 ans = -ans2 ans -ans2 ans2 ans = ans1 ans ans1 print(ans) print ans ans = -max_number -max_number ans ans = -ans2 -ans2 ans X,K,D = list(map(int,input().split())) list(map(int,input().split())) X max_number = X + K*D X + K*D max_number ans1 = max_number - 2*q*D max_number - 2*q*D ans1 q = max_number // (2*D) max_number // (2*D) q ans = min_number min_number ans ans2 = max_number - 2*(q+1)*D max_number - 2*(q+1)*D ans2 min_number = X - K*D X - K*D min_number ans = ans1 ans1 ans D = list(map(int,input().split())) list(map(int,input().split())) D K,D = list(map(int,input().split())) list(map(int,input().split())) K
X,K,D = list(map(int,input().split()))
max_number = X + K*D
min_number = X - K*D
if min_number >= 0:
    ans = min_number
elif max_number <= 0:
    ans = -max_number
else:
    q = max_number // (2*D)
    ans1 = max_number - 2*q*D
    ans2 = max_number - 2*(q+1)*D
    if ans1 > -ans2:
        ans = -ans2
    else:
        ans = ans1
print(ans)
