

startX, countK, distanceD = map(int, input().split())
n = int(abs(startX) / distanceD)
ans = abs(startX) % distanceD
if n > countK:
    ans += distanceD * (n - countK)
else:
    if (countK - n) % 2 == 1:
        ans= abs(ans - distanceD)
print(ans) startX, countK, distanceD = map(int, input().split()) startX map(int, input().split()) map int input().split() ().split () input split countK distanceD n = int(abs(startX) / distanceD) n int(abs(startX) / distanceD) int abs(startX) / distanceD abs(startX) abs startX distanceD ans = abs(startX) % distanceD ans abs(startX) % distanceD abs(startX) abs startX distanceD if n > countK:
    ans += distanceD * (n - countK)
else:
    if (countK - n) % 2 == 1:
        ans= abs(ans - distanceD) n > countK n countK ans += distanceD * (n - countK) ans distanceD * (n - countK) distanceD n - countK n countK if (countK - n) % 2 == 1:
        ans= abs(ans - distanceD) (countK - n) % 2 == 1 (countK - n) % 2 countK - n countK n 2 1 ans= abs(ans - distanceD) ans abs(ans - distanceD) abs ans - distanceD ans distanceD print(ans) print ans ans += distanceD * (n - countK) distanceD * (n - countK) ans ans= abs(ans - distanceD) abs(ans - distanceD) ans ans = abs(startX) % distanceD abs(startX) % distanceD ans n = int(abs(startX) / distanceD) int(abs(startX) / distanceD) n distanceD = map(int, input().split()) map(int, input().split()) distanceD startX, countK, distanceD = map(int, input().split()) map(int, input().split()) startX countK, distanceD = map(int, input().split()) map(int, input().split()) countK


startX, countK, distanceD = map(int, input().split())
n = int(abs(startX) / distanceD)
ans = abs(startX) % distanceD
if n > countK:
    ans += distanceD * (n - countK)
else:
    if (countK - n) % 2 == 1:
        ans= abs(ans - distanceD)
print(ans)
