Let "h" be height of the 3-ary tree.
Since we know that Leaves are present at last level (in case of maximum number of leaves like in Complete 3-ary tree).
So, number of Leaves (say L) will be "atmost" = 3h.
ex- we can have a maximum of L=1 at h=0 (when root itself is leaf)
L=3 at h=1
L=9 at h=2 and so on.
Similarly, Internal nodes are present in maximum at (h-1) height.
So,Number of Internal Nodes (say I) will be "atmost "
=30+31+32+.........3h-1 = 3(h -1)/2
Let n be Total number of nodes, then n= L+I
n= 3h + 3h -1/2
n= 3h+1 -1/2
2n+1=3.L ( since L= 3h)
hence L= (2n+1)/3