Counting the total number of leaf nodes