def abc175_c_3():
    x, k, d = map(int, input().split())

    def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

    ans = solve(x, k, d)
    print(ans)

if __name__ == '__main__':
    abc175_c_3() def abc175_c_3():
    x, k, d = map(int, input().split())

    def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

    ans = solve(x, k, d)
    print(ans) abc175_c_3 x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

     solve """
        https://atcoder.jp/contests/abc175/editorial/52
        """ x = abs(x) x abs(x) abs x straight = int(min(k, x / d)) straight int(min(k, x / d)) int min(k, x / d) min k x / d x d k -= straight k straight x -= straight * d x straight * d straight d if k % 2 == 0:
            return x
        else:
            return abs(x - d)

     k % 2 == 0 k % 2 k 2 0 return x x return abs(x - d) abs(x - d) abs x - d x d x x k k d d ans = solve(x, k, d) ans solve(x, k, d) solve x k d print(ans) print ans if __name__ == '__main__':
    abc175_c_3() __name__ == '__main__' __name__ '__main__' abc175_c_3() abc175_c_3 def abc175_c_3():
    x, k, d = map(int, input().split())

    def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

    ans = solve(x, k, d)
    print(ans) def abc175_c_3():
    x, k, d = map(int, input().split())

    def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

    ans = solve(x, k, d)
    print(ans) abc175_c_3
def abc175_c_3():
    x, k, d = map(int, input().split())

    def solve(x, k, d):
        """
        https://atcoder.jp/contests/abc175/editorial/52
        """

        x = abs(x)

        straight = int(min(k, x / d))
        k -= straight
        x -= straight * d

        if k % 2 == 0:
            return x
        else:
            return abs(x - d)

    ans = solve(x, k, d)
    print(ans)

if __name__ == '__main__':
    abc175_c_3()