program probC
    implicit none
    integer(16)::X, K, D, ans, c
    integer::i, j
    read(*,*) X, K, D
    X = abs(X)
    c = X/D
    if(c >= K)then 
    	write(*,*) X - K*D
    else
        K = K - c
        if(mod(K,2) == 0)then 
        	write(*,*) X - c*D
        else 
            write(*,*) abs(X - (c+1)*D)
        end if
    end if
    stop
end program