UBS investment bank posts profit for Q2