How do I find the distance to the nearest foliage (Landscape Grass Type) spawned using Grass Output node?

I spawn small rocks on my material, but I want to make it seem more realistic by adding indents around the rocks which I can do if I can find the distance to the nearest spawned rock/foliage, but only those rocks/foliages and not just any object so the DistanceToNearestSurface is not applicable (besides I feel as though foliage isn’t counted in the distancetonearest surface node, but I might be wrong)