def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
    return

if __name__ == '__main__':
    main() def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
    return main x,k,d = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
     x < k*d x k*d k d cnt, amari = divmod(x,d) cnt divmod(x,d) divmod x d amari if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
         abs(amari-d) < amari abs(amari-d) abs amari-d amari d amari amari = abs(amari - d) amari abs(amari - d) abs amari - d amari d cnt += 1 cnt 1 if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

     (k-cnt)%2==0 (k-cnt)%2 k-cnt k cnt 2 0 print(amari) print amari print(abs(amari-d)) print abs(amari-d) abs amari-d amari d print(x-k*d) print x-k*d x k*d k d return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
    return def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
    return main
def main():
    x,k,d = map(int,input().split())
    x = abs(x)
    if x < k*d:
        # minimum = min(d-(x%d),x % d)
        cnt, amari = divmod(x,d)
        if abs(amari-d) < amari:
            amari = abs(amari - d)
            cnt += 1
        if (k-cnt)%2==0:
            print(amari)
        else:
            print(abs(amari-d))

    else:
        print(x-k*d)
    return

if __name__ == '__main__':
    main()