The final size of an epidemic in a heterogeneous society