import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

x,k,d = map(int,readline().split())

x = abs(x)
if (x >= k*d):
    print(x-k*d)
elif ((k-x//d)%2):
    print(abs(x%d-d))
else:
    print(x%d) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 INF = 10**18 INF 10**18 10 18 eps = 10**-7 eps 10**-7 10 -7 x,k,d = map(int,readline().split()) x map(int,readline().split()) map int readline().split() ().split () readline split k d x = abs(x) x abs(x) abs x if (x >= k*d):
    print(x-k*d)
elif ((k-x//d)%2):
    print(abs(x%d-d))
else:
    print(x%d) x >= k*d x k*d k d print(x-k*d) print x-k*d x k*d k d elif ((k-x//d)%2):
    print(abs(x%d-d)) (k-x//d)%2 k-x//d k x//d x d 2 print(abs(x%d-d)) print abs(x%d-d) abs x%d-d x%d x d d print(x%d) print x%d x d INF = 10**18 10**18 INF x,k,d = map(int,readline().split()) map(int,readline().split()) x d = map(int,readline().split()) map(int,readline().split()) d eps = 10**-7 10**-7 eps mod = 10**9+7 10**9+7 mod k,d = map(int,readline().split()) map(int,readline().split()) k readline = sys.stdin.readline sys.stdin.readline readline x = abs(x) abs(x) x
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

x,k,d = map(int,readline().split())

x = abs(x)
if (x >= k*d):
    print(x-k*d)
elif ((k-x//d)%2):
    print(abs(x%d-d))
else:
    print(x%d)
