Here we want twice (for two modes) the number points in the positive octant () of the sphere of radius where the volume associated with each point is . (See figure below.)
The total number of points within the octant is then the volume of the octant divided by the volume associated with each point. Including the factor of two for polarization, then
where we have included an estimate of the error as the number of boxes touching the surface of the sphere. Note that as long as the wavelengths which concern are much smaller than the dimensions of the cavity, this is a very good approximation.