# string
# a, b, c = input().split()
# str_list = list(input().split())

# number
# a, b, c = map(int, input().split())
# num_list = list(map(int, input().split()))

# lows
# str_list = [input() for _ in range(n)]

# many inputs
# num_list = []
# for i in range(n): num_list.append(list(map(int, input().split())))

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

if x < 0:
    x = -x

l = int(x/d)

if l < k:
    print(abs(x - ((k-l)%2 + l) * d))
else:
    print(abs(x - k*d)) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d if x < 0:
    x = -x x < 0 x 0 x = -x x -x x l = int(x/d) l int(x/d) int x/d x d if l < k:
    print(abs(x - ((k-l)%2 + l) * d))
else:
    print(abs(x - k*d)) l < k l k print(abs(x - ((k-l)%2 + l) * d)) print abs(x - ((k-l)%2 + l) * d) abs x - ((k-l)%2 + l) * d x ((k-l)%2 + l) * d (k-l)%2 + l (k-l)%2 k-l k l 2 l d print(abs(x - k*d)) print abs(x - k*d) abs x - k*d x k*d k d k, d = map(int, input().split()) map(int, input().split()) k x = -x -x x d = map(int, input().split()) map(int, input().split()) d x, k, d = map(int, input().split()) map(int, input().split()) x l = int(x/d) int(x/d) l
# string
# a, b, c = input().split()
# str_list = list(input().split())

# number
# a, b, c = map(int, input().split())
# num_list = list(map(int, input().split()))

# lows
# str_list = [input() for _ in range(n)]

# many inputs
# num_list = []
# for i in range(n): num_list.append(list(map(int, input().split())))

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

if x < 0:
    x = -x

l = int(x/d)

if l < k:
    print(abs(x - ((k-l)%2 + l) * d))
else:
    print(abs(x - k*d))