import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x))


if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def input(): return sys.stdin.readline().rstrip() input def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x)) main x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d desired = abs(x) // d desired abs(x) // d abs(x) abs x d if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
     k <= desired k desired if x < 0:
            x += k * d
        else:
            x -= k * d
         x < 0 x 0 x += k * d x k * d k d x -= k * d x k * d k d print(abs(x)) print abs(x) abs x return if x < 0:
        x += desired * d
    else:
        x -= desired * d
     x < 0 x 0 x += desired * d x desired * d desired d x -= desired * d x desired * d desired d if (k - desired) % 2 == 0:
        print(abs(x))
        return
     (k - desired) % 2 == 0 (k - desired) % 2 k - desired k desired 2 0 print(abs(x)) print abs(x) abs x return if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x)) x == 0 x 0 print(d) print d elif x > 0:
        x -= d
        print(abs(x))
     x > 0 x 0 x -= d x d print(abs(x)) print abs(x) abs x elif x < 0:
        x += d
        print(abs(x)) x < 0 x 0 x += d x d print(abs(x)) print abs(x) abs x if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x)) def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x)) main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x))


if __name__ == '__main__':
    main()