def main():
    x,k,d = map(int,input().split(" "))

    if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


    if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) )))



if __name__ == '__main__':
    main() def main():
    x,k,d = map(int,input().split(" "))

    if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


    if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) ))) main x,k,d = map(int,input().split(" ")) x map(int,input().split(" ")) map int input().split(" ") ().split () input split " " k d if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


     abs(x) % d == 0 abs(x) % d abs(x) abs x d 0 exceed_num = (abs(x) // d) exceed_num abs(x) // d abs(x) abs x d exceed_num = (abs(x) // d) + 1 exceed_num (abs(x) // d) + 1 abs(x) // d abs(x) abs x d 1 if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) ))) k <= exceed_num k exceed_num print(abs( abs(x) - (d*k) )) print abs( abs(x) - (d*k) ) abs abs(x) - (d*k) abs(x) abs x d*k d k if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) ))) (k - exceed_num) % 2 == 0 (k - exceed_num) % 2 k - exceed_num k exceed_num 2 0 print(abs( abs(x) - (d*exceed_num) )) print abs( abs(x) - (d*exceed_num) ) abs abs(x) - (d*exceed_num) abs(x) abs x d*exceed_num d exceed_num print(abs( abs(x) - (d*(exceed_num-1) ))) print abs( abs(x) - (d*(exceed_num-1) )) abs abs(x) - (d*(exceed_num-1) ) abs(x) abs x d*(exceed_num-1) d exceed_num-1 exceed_num 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    x,k,d = map(int,input().split(" "))

    if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


    if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) ))) def main():
    x,k,d = map(int,input().split(" "))

    if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


    if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) ))) main
def main():
    x,k,d = map(int,input().split(" "))

    if abs(x) % d == 0:
        exceed_num = (abs(x) // d)
    else:
        exceed_num = (abs(x) // d) + 1


    if k <= exceed_num :
        print(abs( abs(x) - (d*k) ))
    else:
        if (k - exceed_num) % 2 == 0:
            print(abs( abs(x) - (d*exceed_num) ))
        else:
            print(abs( abs(x) - (d*(exceed_num-1) )))



if __name__ == '__main__':
    main()