# coding: utf-8
# Your code here!
X,K,D=map(int,input().split())

move=min(abs(X)//D,K)
ans=abs(X)-move*D

if move==K:
    print(ans)
else:
    if (K-move)%2==0:
        print(ans)
    else:
        print(abs(ans-D)) X,K,D=map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D move=min(abs(X)//D,K) move min(abs(X)//D,K) min abs(X)//D abs(X) abs X D K ans=abs(X)-move*D ans abs(X)-move*D abs(X) abs X move*D move D if move==K:
    print(ans)
else:
    if (K-move)%2==0:
        print(ans)
    else:
        print(abs(ans-D)) move==K move K print(ans) print ans if (K-move)%2==0:
        print(ans)
    else:
        print(abs(ans-D)) (K-move)%2==0 (K-move)%2 K-move K move 2 0 print(ans) print ans print(abs(ans-D)) print abs(ans-D) abs ans-D ans D X,K,D=map(int,input().split()) map(int,input().split()) X D=map(int,input().split()) map(int,input().split()) D move=min(abs(X)//D,K) min(abs(X)//D,K) move K,D=map(int,input().split()) map(int,input().split()) K ans=abs(X)-move*D abs(X)-move*D ans
# coding: utf-8
# Your code here!
X,K,D=map(int,input().split())

move=min(abs(X)//D,K)
ans=abs(X)-move*D

if move==K:
    print(ans)
else:
    if (K-move)%2==0:
        print(ans)
    else:
        print(abs(ans-D))