Let the AP have $n$ terms, with first term $a = 9$ and common difference $d$.
First three terms: $a, a + d, a + 2d$
\[\text{Sum} = 3a + 3d = 30 \implies d = 1\]
Last three terms: $a + (n - 3)d, a + (n - 2)d, a + (n - 1)d$
\[\text{Sum} = 3a + 3(n - 3)d = 36 \implies 27 + 3(n - 3) = 36 \implies n = 6\]