A mean counting function for Dirichlet series and compact composition operators