Multi diameters counting
canonical implementation