def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X)

def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y


if __name__ == '__main__':
    X, K, D = map(int, input().split())
    print(execute2(X, K, D)) def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X) execute for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

     i range(K) range K if X > 0:
            X -= D
        else:
            X += D

     X > 0 X 0 X -= D X D X += D X D return abs(X) abs(X) abs X X X K K D D def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y execute2 T = int(abs(X) / D) T int(abs(X) / D) int abs(X) / D abs(X) abs X D if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y X > 0 X 0 if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
     K < T K T return X - K * D X - K * D X K * D K D Y = X - T * D Y X - T * D X T * D T D if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
     (K - T) % 2 == 0 (K - T) % 2 K - T K T 2 0 return Y Y return D - Y D - Y D Y if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y K < T K T return (X + K * D) * -1 (X + K * D) * -1 X + K * D X K * D K D -1 Y = X + T * D Y X + T * D X T * D T D if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y (K - T) % 2 == 0 (K - T) % 2 K - T K T 2 0 return -1 * Y -1 * Y -1 Y return D + Y D + Y D Y X X K K D D if __name__ == '__main__':
    X, K, D = map(int, input().split())
    print(execute2(X, K, D)) __name__ == '__main__' __name__ '__main__' X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D print(execute2(X, K, D)) print execute2(X, K, D) execute2 X K D D = map(int, input().split()) map(int, input().split()) D def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X) def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X) execute X, K, D = map(int, input().split()) map(int, input().split()) X def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y execute2 K, D = map(int, input().split()) map(int, input().split()) K
def execute(X, K, D):
    for i in range(K):
        if X > 0:
            X -= D
        else:
            X += D

    return abs(X)

def execute2(X, K, D):
    T = int(abs(X) / D)
    if X > 0:
        if K < T:
            return X - K * D
        else:
            Y = X - T * D
            if (K - T) % 2 == 0:
                return Y
            else:
                return D - Y
    else:
        if K < T:
            return (X + K * D) * -1
        else:
            Y = X + T * D
            if (K - T) % 2 == 0:
                return -1 * Y
            else:
                return D + Y


if __name__ == '__main__':
    X, K, D = map(int, input().split())
    print(execute2(X, K, D))