Distribution of eigenfrequencies for the wave equation in a finite domain. II. Electromagnetic field. Riemannian spaces