# import sys

# import math #sqrt,gcd,pi

# import decimal

# import queue # queue

# import bisect

# import heapq # priolity-queue

# import time

# from itertools import product,permutations,\

    # combinations,combinations_with_replacement

# 重複あり順列、順列、組み合わせ、重複あり組み合わせ

# import collections # deque

# from operator import itemgetter,mul

# from fractions import Fraction

# from functools import reduce



mod = int(1e9+7)

# mod = 998244353

INF = 1<<50



def readInt():

    return list(map(int,input().split()))



def main():

    x,k,d = readInt()

    count = abs(x) // d

    mn = 0

    if count>k:

        mn = abs(x) - (d * k)

        print(mn)

        return

    else:

        mn = abs(x) % d

    ans = INF

    if (k-count)%2==0:

        ans = mn

    else:

        ans = abs(mn-d)

    print(ans)

    return



if __name__=='__main__':

    main()

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

# 原点に近い位置までの移動回数を求める

count = abs(X) // D

ans = 0

if count>K:

    ans = abs(X) - D * K

else:

    if (K-count)%2==0:

        ans = abs(X) % D

    else:

        ans = abs(abs(X) % D - D)

print(ans)
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
# combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce
mod = int(1e9 + 7)
# mod = 998244353
INF = 1 << 50


def readInt():
    return list(map(int, input().split()))


def main():
    x, k, d = readInt()
    count = abs(x) // d
    mn = 0
    if count > k:
        mn = abs(x) - (d * k)
        print(mn)
        return
    else:
        mn = abs(x) % d
    ans = INF
    if (k - count) % 2 == 0:
        ans = mn
    else:
        ans = abs(mn - d)
    print(ans)
    return


if __name__ == "__main__":
    main()

X, K, D = list(map(int, input().split()))
# 原点に近い位置までの移動回数を求める
count = abs(X) // D
ans = 0
if count > K:
    ans = abs(X) - D * K
else:
    if (K - count) % 2 == 0:
        ans = abs(X) % D
    else:
        ans = abs(abs(X) % D - D)
print(ans)

-# import sys -# import math #sqrt,gcd,pi -# import decimal -# import queue # queue -# import bisect -# import heapq # priolity-queue -# import time -# from itertools import product,permutations,\ -# combinations,combinations_with_replacement -# 重複あり順列、順列、組み合わせ、重複あり組み合わせ -# import collections # deque -# from operator import itemgetter,mul -# from fractions import Fraction -# from functools import reduce -mod = int(1e9 + 7) -# mod = 998244353 -INF = 1 << 50 - - -def readInt(): -    return list(map(int, input().split())) - - -def main(): -    x, k, d = readInt() -    count = abs(x) // d -    mn = 0 -    if count > k: -        mn = abs(x) - (d * k) -        print(mn) -        return +X, K, D = list(map(int, input().split())) +# 原点に近い位置までの移動回数を求める +count = abs(X) // D +ans = 0 +if count > K: +    ans = abs(X) - D * K +else: +    if (K - count) % 2 == 0: +        ans = abs(X) % D -        mn = abs(x) % d -    ans = INF -    if (k - count) % 2 == 0: -        ans = mn -    else: -        ans = abs(mn - d) -    print(ans) -    return - - -if __name__ == "__main__": -    main() +        ans = abs(abs(X) % D - D) +print(ans)