Solution (source code)

= Solution

Treat each arriving caterpillar as one customer in an <M-G-infinity queue>, with arrival rate $\lambda$ and service time equal to the sum of its three independent exponential stage lifetimes. This is an Erlang distribution of shape three and rate $\mu$, of mean $3/\mu$. Poisson arrivals independently retained according to whether their service has ended give, in stationarity, a Poisson number in service with mean
$$
\lambda\int_0^\infty P(S>s)\,ds=\lambda\mathbb ES=3\lambda/\mu.
$$
This is exactly the marginal law of $N$ found above. Each individual remains in service across both metamorphoses; counting a fresh service arrival at each stage would be incorrect.