x, k, d = map(int, input().split())
cur = x
numTimes = x // d
if numTimes == 0:
    cur -= d
    k -= 1
else:
    numTimes = min(abs(numTimes), k)
    if x < 0:
        numTimes *= -1
    cur -= numTimes * d
    k -= numTimes
if k % 2 == 0:
    print(abs(cur))
else:
    result = min(abs(cur - d), abs(cur + d))
    print(result) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d cur = x cur x numTimes = x // d numTimes x // d x d if numTimes == 0:
    cur -= d
    k -= 1
else:
    numTimes = min(abs(numTimes), k)
    if x < 0:
        numTimes *= -1
    cur -= numTimes * d
    k -= numTimes numTimes == 0 numTimes 0 cur -= d cur d k -= 1 k 1 numTimes = min(abs(numTimes), k) numTimes min(abs(numTimes), k) min abs(numTimes) abs numTimes k if x < 0:
        numTimes *= -1
     x < 0 x 0 numTimes *= -1 numTimes -1 cur -= numTimes * d cur numTimes * d numTimes d k -= numTimes k numTimes if k % 2 == 0:
    print(abs(cur))
else:
    result = min(abs(cur - d), abs(cur + d))
    print(result) k % 2 == 0 k % 2 k 2 0 print(abs(cur)) print abs(cur) abs cur result = min(abs(cur - d), abs(cur + d)) result min(abs(cur - d), abs(cur + d)) min abs(cur - d) abs cur - d cur d abs(cur + d) abs cur + d cur d print(result) print result k, d = map(int, input().split()) map(int, input().split()) k result = min(abs(cur - d), abs(cur + d)) min(abs(cur - d), abs(cur + d)) result cur = x x cur numTimes = min(abs(numTimes), k) min(abs(numTimes), k) numTimes numTimes = x // d x // d numTimes x, k, d = map(int, input().split()) map(int, input().split()) x k -= 1 1 k cur -= numTimes * d numTimes * d cur k -= numTimes numTimes k cur -= d d cur d = map(int, input().split()) map(int, input().split()) d numTimes *= -1 -1 numTimes
x, k, d = map(int, input().split())
cur = x
numTimes = x // d
if numTimes == 0:
    cur -= d
    k -= 1
else:
    numTimes = min(abs(numTimes), k)
    if x < 0:
        numTimes *= -1
    cur -= numTimes * d
    k -= numTimes
if k % 2 == 0:
    print(abs(cur))
else:
    result = min(abs(cur - d), abs(cur + d))
    print(result)