We just have to do a tree traversal and for leaf nodes return 1 and for other nodes call the function recursively on the left and right nodes and return their sum. The following code would do
int fun (node * x)
{
if(!x) return 0;
if(x -> left == NULL && x-> right == NULL) return 1;
return fun(x->left) + fun(x->right);
}
And tree traversal is $\Theta(n)$.