import sys

input = sys.stdin.readline





def main():

    x, k, d = list(map(int, input().split()))



    if x < 0:

        step = abs(x) // d

        if step >= k:

            ans = abs(x + k*d)

        else:

            residue = k - step

            residue %= 2

            ans = abs(x + (step+residue)*d)



    elif x == 0:

        k %= 2

        ans = k * d

    else:

        step = abs(x) // d

        if step >= k:

            ans = abs(x - k*d)

        else:

            residue = k - step

            residue %= 2

            ans = abs(x - (step+residue)*d)



    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)

    step = x // d

    if step >= k:

        ans = x - d * k

        print(ans)

        return



    k -= step

    x = x - step * d

    k %= 2

    ans = abs(x - d*k)

    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    x, k, d = list(map(int, input().split()))
    if x < 0:
        step = abs(x) // d
        if step >= k:
            ans = abs(x + k * d)
        else:
            residue = k - step
            residue %= 2
            ans = abs(x + (step + residue) * d)
    elif x == 0:
        k %= 2
        ans = k * d
    else:
        step = abs(x) // d
        if step >= k:
            ans = abs(x - k * d)
        else:
            residue = k - step
            residue %= 2
            ans = abs(x - (step + residue) * d)
    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)
    step = x // d
    if step >= k:
        ans = x - d * k
        print(ans)
        return
    k -= step
    x = x - step * d
    k %= 2
    ans = abs(x - d * k)
    print(ans)


if __name__ == "__main__":
    main()

-    if x < 0: -        step = abs(x) // d -        if step >= k: -            ans = abs(x + k * d) -        else: -            residue = k - step -            residue %= 2 -            ans = abs(x + (step + residue) * d) -    elif x == 0: -        k %= 2 -        ans = k * d -    else: -        step = abs(x) // d -        if step >= k: -            ans = abs(x - k * d) -        else: -            residue = k - step -            residue %= 2 -            ans = abs(x - (step + residue) * d) +    x = abs(x) +    step = x // d +    if step >= k: +        ans = x - d * k +        print(ans) +        return +    k -= step +    x = x - step * d +    k %= 2 +    ans = abs(x - d * k)