program C175
    implicit none
    integer(8) :: X, K, D
    integer(8) :: i, j

    read(5,*) X, K, D
    X = abs(X)

    i = X / D
    j = X - D*i

    if (K <= i) then
        write(6,*) X - D*K
    else
        if (mod(K-i,2) == 0) then
            write(6,*) j
        else
            write(6,*) abs(j-D)
        end if
    end if





    
end program C175