import sys

import numpy as np

import math

import collections

import copy

from collections import deque 

from functools import reduce

from itertools import product

from itertools import combinations



# input = sys.stdin.readline

Xa, K, D = list(map(int, input().split()))

X = abs(Xa)

Xs = X // D

Xm = X % D

if K < Xs:

#     print("A")

    print((abs(X-K*D)))

elif Xa == 0:

    if K % 2 == 0:

        print((0))

    else:

        print(D)

elif Xm == 0:

    if K % 2 == 0:

        print(D)

    else:

        print((0))

elif ((K-Xs) % 2 == 0):

    print((abs(Xm)))

else:

    print((abs(D-Xm)))



























Xa, K, D = list(map(int, input().split()))



X = abs(Xa)

Xs = X // D

Xm = X % D



if K < Xs:

#     print("A")

    print((abs(X-K*D)))

elif Xa == 0:

    if K % 2 == 0:

        print((0))

    else:

        print(D)

elif Xm == 0:

    if K % 2 == 0:

        print(D)

    else:

        print((0))

elif ((K-Xs) % 2 == 0):

    print((abs(Xm)))

else:

    print((abs(D-Xm)))

# else:



import sys
import numpy as np
import math
import collections
import copy
from collections import deque
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
Xa, K, D = list(map(int, input().split()))
X = abs(Xa)
Xs = X // D
Xm = X % D
if K < Xs:
    #     print("A")
    print((abs(X - K * D)))
elif Xa == 0:
    if K % 2 == 0:
        print((0))
    else:
        print(D)
elif Xm == 0:
    if K % 2 == 0:
        print(D)
    else:
        print((0))
elif (K - Xs) % 2 == 0:
    print((abs(Xm)))
else:
    print((abs(D - Xm)))

Xa, K, D = list(map(int, input().split()))
X = abs(Xa)
Xs = X // D
Xm = X % D
if K < Xs:
    #     print("A")
    print((abs(X - K * D)))
elif Xa == 0:
    if K % 2 == 0:
        print((0))
    else:
        print(D)
elif Xm == 0:
    if K % 2 == 0:
        print(D)
    else:
        print((0))
elif (K - Xs) % 2 == 0:
    print((abs(Xm)))
else:
    print((abs(D - Xm)))
# else:

-import sys -import numpy as np -import math -import collections -import copy -from collections import deque -from functools import reduce -from itertools import product -from itertools import combinations - -# input = sys.stdin.readline +# else: