import sys

input = sys.stdin.readline

import math





def read():

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

    return X, K, D





def solve(X, K, D):

    m = (-X + K*D) / (2*D)

    mc = min(max(0, math.ceil(m)), K)

    mf = min(max(0, math.floor(m)), K)

    ans = min(abs(X - K*D + 2 * mc * D), abs(X - K*D + 2 * mf * D))

    return ans





if __name__ == '__main__':

    inputs = read()

    outputs = solve(*inputs)

    if outputs is not None:

        print(("%s" % str(outputs)))

import sys

input = sys.stdin.readline

import math





def read():

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

    return X, K, D





def solve(X, K, D):

    X = abs(X)

    k = X // D 

    if K % 2 == 0:

        if k % 2 == 0:

            i = min(X // D, K)

        else:

            i = min(X // D + 1, K)

    else:

        if k % 2 == 0:

            i = min(X // D + 1, K)

        else:

            i = min(X // D, K)

    ans = X - i * D

    return abs(ans)





if __name__ == '__main__':

    inputs = read()

    outputs = solve(*inputs)

    if outputs is not None:

        print(("%s" % str(outputs)))

import sys

input = sys.stdin.readline
import math


def read():
    X, K, D = list(map(int, input().strip().split()))
    return X, K, D


def solve(X, K, D):
    m = (-X + K * D) / (2 * D)
    mc = min(max(0, math.ceil(m)), K)
    mf = min(max(0, math.floor(m)), K)
    ans = min(abs(X - K * D + 2 * mc * D), abs(X - K * D + 2 * mf * D))
    return ans


if __name__ == "__main__":
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print(("%s" % str(outputs)))

import sys

input = sys.stdin.readline
import math


def read():
    X, K, D = list(map(int, input().strip().split()))
    return X, K, D


def solve(X, K, D):
    X = abs(X)
    k = X // D
    if K % 2 == 0:
        if k % 2 == 0:
            i = min(X // D, K)
        else:
            i = min(X // D + 1, K)
    else:
        if k % 2 == 0:
            i = min(X // D + 1, K)
        else:
            i = min(X // D, K)
    ans = X - i * D
    return abs(ans)


if __name__ == "__main__":
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print(("%s" % str(outputs)))

-    m = (-X + K * D) / (2 * D) -    mc = min(max(0, math.ceil(m)), K) -    mf = min(max(0, math.floor(m)), K) -    ans = min(abs(X - K * D + 2 * mc * D), abs(X - K * D + 2 * mf * D)) -    return ans +    X = abs(X) +    k = X // D +    if K % 2 == 0: +        if k % 2 == 0: +            i = min(X // D, K) +        else: +            i = min(X // D + 1, K) +    else: +        if k % 2 == 0: +            i = min(X // D + 1, K) +        else: +            i = min(X // D, K) +    ans = X - i * D +    return abs(ans)