See Keith Conrad's notes http://www.math.uconn.edu/~kconrad/blurbs/grouptheory/SL(2,Z).pdf, particularly Example 2.5. Let us write (as Conrad does) $S = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$ and $T = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}$. Then $S$ has order $4$ and $ST = \begin{pmatrix} 0 & -1 \\ 1 & 1 \end{pmatrix}$ has order $6$. In his Example 2.5, Conrad displays a character $\chi : SL_2(\mathbb{Z}) \to \mathbb{C}^*$ taking $S$ to a primitive $4$th root of unity and $ST$ to a primitive $6$th root of unity. So $\chi(T) = \chi(S)^{-1} \chi(ST)$ is a primitive $12$th root of unity; in fact Conrad's example has $\chi(T) = e^{2\pi i/12}$. And $\chi(A)$$\chi(M)$ has this same value for any matrix $A$$M$ conjugate to $T$.
At this point perhaps it is obvious, but to be clear: if $A_1,\dotsc,A_k$$M_1,\dotsc,M_n$ are each conjugate to $T$ and $A_1 \dotsm A_k$$M_1 \dotsm M_n$ is the identity, then $1 = \prod \chi(A_i) = \chi(T)^k$$1 = \chi(\prod M_i) = \prod \chi(M_i) = \chi(T)^n = e^{2 \pi i \, n/12}$, so $12 \mid k$ since $\chi(T)$ is a primitive $12$th root of unity$12 \mid n$.