from sys import stdin
input = stdin.readline
X, K, D = map(int, input().split())
A=int((K-X/D)/2)
if 0<=A and A<=K:print(min(abs(-K*D+2*A*D+X),abs(-K*D+2*(A+1)*D+X)))
else:print(min(abs(X+K*D),abs(X-K*D))) from sys import stdin input = stdin.readline input stdin.readline stdin readline X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D A=int((K-X/D)/2) A int((K-X/D)/2) int (K-X/D)/2 K-X/D K X/D X D 2 if 0<=A and A<=K:print(min(abs(-K*D+2*A*D+X),abs(-K*D+2*(A+1)*D+X)))
else:print(min(abs(X+K*D),abs(X-K*D))) 0<=A and A<=K 0<=A 0 A A<=K A K A=int((K-X/D)/2) int((K-X/D)/2) A input = stdin.readline stdin.readline input D = map(int, input().split()) map(int, input().split()) D K, D = map(int, input().split()) map(int, input().split()) K X, K, D = map(int, input().split()) map(int, input().split()) X
from sys import stdin
input = stdin.readline
X, K, D = map(int, input().split())
A=int((K-X/D)/2)
if 0<=A and A<=K:print(min(abs(-K*D+2*A*D+X),abs(-K*D+2*(A+1)*D+X)))
else:print(min(abs(X+K*D),abs(X-K*D)))