Look at the following representations:
RHS is left child Right-Sibling representation. Those nodes which are leaf nodes in LHS tree, have become nodes without left child in RHS tree.
For example $N,O,I,JC,D,P,Q,F,M$ are leaf nodes in LHS tree, and if you notice then these nodes don't have Left Child in equivalent RHS Left Child Right-Sibling Tree, hence this code given above is counting the number if leaf nodes in the tree.