import sys



input = sys.stdin.readline





def main():

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



    X = abs(X)

    q, r = divmod(X, D)

    if K <= q:

        ans = (q - K) * D + r

    else:

        if (K - q) % 2 == 0:

            ans = r

        else:

            ans = D - r



    print(ans)





if __name__ == "__main__":

    main()

import sys



input = sys.stdin.readline





def main():

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



    X = abs(X)

    q, r = divmod(X, D)

    if K < q:

        ans = X - D * K

    else:

        if (K - q) % 2 == 0:

            ans = r

        else:

            ans = D - r



    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    X, K, D = list(map(int, input().split()))
    X = abs(X)
    q, r = divmod(X, D)
    if K <= q:
        ans = (q - K) * D + r
    else:
        if (K - q) % 2 == 0:
            ans = r
        else:
            ans = D - r
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    X, K, D = list(map(int, input().split()))
    X = abs(X)
    q, r = divmod(X, D)
    if K < q:
        ans = X - D * K
    else:
        if (K - q) % 2 == 0:
            ans = r
        else:
            ans = D - r
    print(ans)


if __name__ == "__main__":
    main()

-    if K <= q: -        ans = (q - K) * D + r +    if K < q: +        ans = X - D * K