"""
AtCoder :: Beginner Contest 175 :: C - Walking Takahashi 
https://atcoder.jp/contests/abc175/tasks/abc175_c
"""
import sys


def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln


def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D))


if __name__ == '__main__':
    main() """
AtCoder :: Beginner Contest 175 :: C - Walking Takahashi 
https://atcoder.jp/contests/abc175/tasks/abc175_c
""" import sys sys def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln solve """Solve puzzle.""" if D == 0:
        return X

     D == 0 D 0 return X X X = abs(X) X abs(X) abs X soln = abs(X - (K * D)) soln abs(X - (K * D)) abs X - (K * D) X K * D K D steps_to_zero = abs(X) // D steps_to_zero abs(X) // D abs(X) abs X D if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
     steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0) steps_to_zero <= K steps_to_zero K (K - steps_to_zero) % 2 == 0 (K - steps_to_zero) % 2 K - steps_to_zero K steps_to_zero 2 0 soln = min(soln, abs(X - (steps_to_zero * D))) soln min(soln, abs(X - (steps_to_zero * D))) min soln abs(X - (steps_to_zero * D)) abs X - (steps_to_zero * D) X steps_to_zero * D steps_to_zero D steps_past_zero = steps_to_zero + 1 steps_past_zero steps_to_zero + 1 steps_to_zero 1 if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
     steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0) steps_past_zero <= K steps_past_zero K (K - steps_past_zero) % 2 == 0 (K - steps_past_zero) % 2 K - steps_past_zero K steps_past_zero 2 0 soln = min(soln, abs(X - (steps_past_zero * D))) soln min(soln, abs(X - (steps_past_zero * D))) min soln abs(X - (steps_past_zero * D)) abs X - (steps_past_zero * D) X steps_past_zero * D steps_past_zero D steps_back_zero = steps_past_zero + 1 steps_back_zero steps_past_zero + 1 steps_past_zero 1 if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

     steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0) steps_back_zero <= K steps_back_zero K (K - steps_back_zero) % 2 == 0 (K - steps_back_zero) % 2 K - steps_back_zero K steps_back_zero 2 0 soln = min(soln, abs(X - (steps_back_zero * D))) soln min(soln, abs(X - (steps_back_zero * D))) min soln abs(X - (steps_back_zero * D)) abs X - (steps_back_zero * D) X steps_back_zero * D steps_back_zero D return soln soln X X K K D D def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D)) main """Main program.""" int(i) for i in sys.stdin.readline().split() for i in sys.stdin.readline().split() i sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for i in sys.stdin.readline().split() int(i) int i X, K, D = (int(i) for i in sys.stdin.readline().split()) X (int(i) for i in sys.stdin.readline().split()) K D print(solve(X, K, D)) print solve(X, K, D) solve X K D if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln solve def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D)) def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D)) main
"""
AtCoder :: Beginner Contest 175 :: C - Walking Takahashi 
https://atcoder.jp/contests/abc175/tasks/abc175_c
"""
import sys


def solve(X, K, D):
    """Solve puzzle."""
    # print('solve X', X, 'K', K, 'D', D)
    if D == 0:
        return X

    X = abs(X)
    soln = abs(X - (K * D))
    steps_to_zero = abs(X) // D
    # print('steps to zero', steps_to_zero, K - steps_to_zero)
    # print('to zero', abs(X - (steps_to_zero * D)))
    # Undershoot or get directly on to zero.
    if steps_to_zero <= K and ((K - steps_to_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_to_zero * D)))

    # Overshoot by one step
    steps_past_zero = steps_to_zero + 1
    # print('steps past zero', steps_past_zero, K - steps_past_zero)
    # print('past zero', abs(X - (steps_past_zero * D))) 
    if steps_past_zero <= K and ((K - steps_past_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_past_zero * D)))

    # Overshoot and return by one
    steps_back_zero = steps_past_zero + 1
    # print('steps back zero', steps_back_zero, K - steps_back_zero)
    # print('back zero', abs(X - (steps_back_zero * D)))
    if steps_back_zero <= K and ((K - steps_back_zero) % 2 == 0):
        soln = min(soln, abs(X - (steps_back_zero * D)))

    return soln


def main():
    """Main program."""
    X, K, D = (int(i) for i in sys.stdin.readline().split())
    print(solve(X, K, D))


if __name__ == '__main__':
    main()
