Count number of children element

I would like to automatically count the number of children element for several assets. I m aware of the roll up method with an attribut = 1. Nevertheless, I would like that the system be able to count 0 when there is no children at all. The roll up does'nt work well and goes to error in this case.