# -*- coding: utf-8
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(int(x))
else:
    print(int(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(int(x))
else:
    print(int(d-x)) k%2==0 k%2 k 2 0 print(int(x)) print int(x) int x print(int(d-x)) print int(d-x) int d-x d x k,d = map(int,input().split()) map(int,input().split()) k x,k,d = map(int,input().split()) map(int,input().split()) x d = map(int,input().split()) map(int,input().split()) d x = abs(x) abs(x) x k -= straight straight k x -= straight*d straight*d x straight = min(k,x//d) min(k,x//d) straight
# -*- coding: utf-8
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(int(x))
else:
    print(int(d-x))