X,K,D=map(int,input().split())
X=abs(X)
straight=min(K,X//D)
K-=straight
X-=straight*D
if K%2==0:
    print(X)
else:
    print(D-X) X,K,D=map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D X=abs(X) X abs(X) abs X straight=min(K,X//D) straight min(K,X//D) min K X//D X D K-=straight K straight X-=straight*D X straight*D straight D if K%2==0:
    print(X)
else:
    print(D-X) K%2==0 K%2 K 2 0 print(X) print X print(D-X) print D-X D X K-=straight straight K K,D=map(int,input().split()) map(int,input().split()) K D=map(int,input().split()) map(int,input().split()) D X,K,D=map(int,input().split()) map(int,input().split()) X X=abs(X) abs(X) X X-=straight*D straight*D X straight=min(K,X//D) min(K,X//D) straight
X,K,D=map(int,input().split())
X=abs(X)
straight=min(K,X//D)
K-=straight
X-=straight*D
if K%2==0:
    print(X)
else:
    print(D-X)