Count the number of nodes in the tree