from math import floor, ceil

def solve(X, D, lb, ub):
    # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
    ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ]
    return min([abs(X + t * D) for t in ts])

X, K, D = map(int, input().split())
if K % 2 == 0:
    ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
    ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
    ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
    ans = min(ans1, ans2)
print(ans)
 from math import floor, ceil def solve(X, D, lb, ub):
    # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
    ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ]
    return min([abs(X + t * D) for t in ts]) solve ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ] ts [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ] lb ub max(min(floor(-X / D), ub), lb) max min(floor(-X / D), ub) min floor(-X / D) floor -X / D -X X D ub lb max(min(ceil(-X / D), ub), lb) max min(ceil(-X / D), ub) min ceil(-X / D) ceil -X / D -X X D ub lb abs(X + t * D) for t in ts for t in ts t ts for t in ts abs(X + t * D) abs X + t * D X t * D t D return min([abs(X + t * D) for t in ts]) min([abs(X + t * D) for t in ts]) min [abs(X + t * D) for t in ts] X X D D lb lb ub ub X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if K % 2 == 0:
    ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
    ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
    ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
    ans = min(ans1, ans2) K % 2 == 0 K % 2 K 2 0 ans = solve(X, D * 2, -(K // 2), +(K // 2)) ans solve(X, D * 2, -(K // 2), +(K // 2)) solve X D * 2 D 2 -(K // 2) K // 2 K 2 +(K // 2) K // 2 K 2 ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) ans1 solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) solve X + D X D D * 2 D 2 -((K + 1) // 2) (K + 1) // 2 K + 1 K 1 2 +((K - 1)) // 2 +((K - 1)) K - 1 K 1 2 ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2) ans2 solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2) solve X - D X D D * 2 D 2 -((K - 1) // 2) (K - 1) // 2 K - 1 K 1 2 +((K + 1)) // 2 +((K + 1)) K + 1 K 1 2 ans = min(ans1, ans2) ans min(ans1, ans2) min ans1 ans2 print(ans) print ans K, D = map(int, input().split()) map(int, input().split()) K X, K, D = map(int, input().split()) map(int, input().split()) X D = map(int, input().split()) map(int, input().split()) D ans = solve(X, D * 2, -(K // 2), +(K // 2)) solve(X, D * 2, -(K // 2), +(K // 2)) ans ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2) solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2) ans2 def solve(X, D, lb, ub):
    # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
    ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ]
    return min([abs(X + t * D) for t in ts]) def solve(X, D, lb, ub):
    # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
    ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ]
    return min([abs(X + t * D) for t in ts]) solve ans = min(ans1, ans2) min(ans1, ans2) ans ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) ans1
from math import floor, ceil

def solve(X, D, lb, ub):
    # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int)
    ts = [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(ceil(-X / D), ub), lb),
    ]
    return min([abs(X + t * D) for t in ts])

X, K, D = map(int, input().split())
if K % 2 == 0:
    ans = solve(X, D * 2, -(K // 2), +(K // 2))
else:
    ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2)
    ans2 = solve(X - D, D * 2, -((K - 1) // 2), +((K + 1)) // 2)
    ans = min(ans1, ans2)
print(ans)

