Counting unused materials

Is it way to count unused material in scene. By unused I mean materials which are not attached to any object on scene. I tried this:

for i = 1 to 24 where not MeditUtilities.isMaterialInUse meditMaterials[i] collect meditMaterials[i]

but it also include defoult grey materials from material editor but I have to count not attached materials(defined by user )
Is it possible?