from math import floor

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(floor(-X / D) + 1, ub), lb),
    ]   
    return min([abs(X + t * D) for t in ts])

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

y1 = X - K * D
y2 = X + K * D
if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign
    print(min(abs(y1), abs(y2)))
else:
    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 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(floor(-X / D) + 1, 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(floor(-X / D) + 1, ub), lb),
    ] ts [
        lb,
        ub,
        max(min(floor(-X / D), ub), lb),
        max(min(floor(-X / D) + 1, 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(floor(-X / D) + 1, ub), lb) max min(floor(-X / D) + 1, ub) min floor(-X / D) + 1 floor(-X / D) floor -X / D -X X D 1 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 y1 = X - K * D y1 X - K * D X K * D K D y2 = X + K * D y2 X + K * D X K * D K D if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign
    print(min(abs(y1), abs(y2)))
else:
    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) (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0) y1 > 0 and y2 > 0 y1 > 0 y1 0 y2 > 0 y2 0 y1 < 0 and y2 < 0 y1 < 0 y1 0 y2 < 0 y2 0 print(min(abs(y1), abs(y2))) print min(abs(y1), abs(y2)) min abs(y1) abs y1 abs(y2) abs y2 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 D = map(int, input().split()) map(int, input().split()) D ans1 = solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) solve(X + D, D * 2, -((K + 1) // 2), +((K - 1)) // 2) ans1 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 y2 = X + K * D X + K * D y2 K, D = map(int, input().split()) map(int, input().split()) K X, K, D = map(int, input().split()) map(int, input().split()) X y1 = X - K * D X - K * D y1 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(floor(-X / D) + 1, 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(floor(-X / D) + 1, ub), lb),
    ]   
    return min([abs(X + t * D) for t in ts]) solve ans = min(ans1, ans2) min(ans1, ans2) ans
from math import floor

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(floor(-X / D) + 1, ub), lb),
    ]   
    return min([abs(X + t * D) for t in ts])

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

y1 = X - K * D
y2 = X + K * D
if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign
    print(min(abs(y1), abs(y2)))
else:
    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)

