Step 1: Count the legs from the humans.
There are 9 humans, each with 2 legs, so humans contribute \(9 \times 2 = 18\) legs.
Step 2: Count how many lions there are, then their legs.
Each of the 9 humans has 9 cages, and each cage has 9 lions, so the number of lions is \(9 \times 9 \times 9 = 729\). Each lion has 4 legs, so lions contribute \(729 \times 4 = 2916\) legs.
Step 3: Count how many cubs there are, then their legs.
Each of the 729 lions has 9 cubs, so the number of cubs is \(729 \times 9 = 6561\). Each cub has 4 legs, so cubs contribute \(6561 \times 4 = 26244\) legs.
Step 4: Add up all the legs.
Total legs = \(18 + 2916 + 26244 = 29178\).
Final Answer:
There are 29178 legs in the ship.
\[ \boxed{29178} \]