Ruthenium and hafnium abundances in giant and dwarf barium stars