def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip())) def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d) solve x, k, d = map(int, string.split()) x map(int, string.split()) map int string.split() string.split string split k d x = abs(x) x abs(x) abs x if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
     k % 2 k 2 x = min(x - d, x + d, key=abs) x min(x - d, x + d, key=abs) min x - d x d x + d x d key=abs key abs k -= 1 k 1 k, d = k // 2, d * 2 k k // 2 k 2 d d * 2 d 2 if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d) x < k * d x k * d k d return str(min(x % d, abs((x % d) - d))) str(min(x % d, abs((x % d) - d))) str min(x % d, abs((x % d) - d)) min x % d x d abs((x % d) - d) abs (x % d) - d x % d x d d return str(x - k * d) str(x - k * d) str x - k * d x k * d k d string string if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip())) __name__ == '__main__' __name__ '__main__' import sys sys print(solve(sys.stdin.read().strip())) print solve(sys.stdin.read().strip()) solve sys.stdin.read().strip() sys.stdin.read().strip sys.stdin.read() sys.stdin.read sys.stdin sys stdin read strip def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d) def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d) solve
def solve(string):
    x, k, d = map(int, string.split())
    x = abs(x)
    if k % 2:
        x = min(x - d, x + d, key=abs)
        k -= 1
    k, d = k // 2, d * 2
    if x < k * d:
        return str(min(x % d, abs((x % d) - d)))
    else:
        return str(x - k * d)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
