Europe counts cost of heatwave as Spain PM says more than 500 died