A routine to compute the number of nearby entites.