Step 1: Set up the equation for the profit shares.
Let \( m \) be the number of months B joined after. A invests for 12 months, and B invests for \( 12 - m \) months.
Step 2: Calculate their investment ratios.
\[
\text{A's Investment} = 21000 \times 12, \quad \text{B's Investment} = 36000 \times (12 - m)
\]
Given that their profits are equal:
\[
21000 \times 12 = 36000 \times (12 - m)
\]
\[
252000 = 36000 \times (12 - m)
\]
\[
\frac{252000}{36000} = 12 - m
\]
\[
7 = 12 - m
\]
\[
m = 5
\]