X, K, D = [int(x) for x in input().split(" ")]

result = 0
if abs(X) > K * D:
    result = abs(X) - K * D
else:
    y = int(round(abs(X) / D))
    resX = abs(abs(X) - D * y)
    resK = K - y
    if resK % 2 == 1:
        result = abs(resX - D)
    else:
        result = resX
print(result) int(x) for x in input().split(" ") for x in input().split(" ") x input().split(" ") ().split () input split " " for x in input().split(" ") int(x) int x X, K, D = [int(x) for x in input().split(" ")] X [int(x) for x in input().split(" ")] K D result = 0 result 0 if abs(X) > K * D:
    result = abs(X) - K * D
else:
    y = int(round(abs(X) / D))
    resX = abs(abs(X) - D * y)
    resK = K - y
    if resK % 2 == 1:
        result = abs(resX - D)
    else:
        result = resX abs(X) > K * D abs(X) abs X K * D K D result = abs(X) - K * D result abs(X) - K * D abs(X) abs X K * D K D y = int(round(abs(X) / D)) y int(round(abs(X) / D)) int round(abs(X) / D) round abs(X) / D abs(X) abs X D resX = abs(abs(X) - D * y) resX abs(abs(X) - D * y) abs abs(X) - D * y abs(X) abs X D * y D y resK = K - y resK K - y K y if resK % 2 == 1:
        result = abs(resX - D)
    else:
        result = resX resK % 2 == 1 resK % 2 resK 2 1 result = abs(resX - D) result abs(resX - D) abs resX - D resX D result = resX result resX print(result) print result resK = K - y K - y resK result = abs(resX - D) abs(resX - D) result y = int(round(abs(X) / D)) int(round(abs(X) / D)) y result = 0 0 result D = [int(x) for x in input().split(" ")] [int(x) for x in input().split(" ")] D K, D = [int(x) for x in input().split(" ")] [int(x) for x in input().split(" ")] K resX = abs(abs(X) - D * y) abs(abs(X) - D * y) resX X, K, D = [int(x) for x in input().split(" ")] [int(x) for x in input().split(" ")] X result = abs(X) - K * D abs(X) - K * D result result = resX resX result
X, K, D = [int(x) for x in input().split(" ")]

result = 0
if abs(X) > K * D:
    result = abs(X) - K * D
else:
    y = int(round(abs(X) / D))
    resX = abs(abs(X) - D * y)
    resK = K - y
    if resK % 2 == 1:
        result = abs(resX - D)
    else:
        result = resX
print(result)
