I am having some trouble proving that order of $SL_2(Z_3)$ is 24, First I know that the number of elements in $M_2(Z_3)$ is 81 because we have four entries and for each entry we have 3 different possibility and so $3^4 = 81$. Now I already showed that $SL_2(Z_3)$ is a subgroup of $GL_2(Z_3)$ And for $GL_2(Z_3)$ we obviously don't have the zero matrix (81 -1 = 80) and then any of the matrices in the form of $\begin{bmatrix} 0 & 0 \\[0.3em] a & b \\[0.3em] \end{bmatrix}$ do not belong to $GL_2(Z_3)$ and so we have (80 - 3x3) but we exclude the zero matrix so we have (80 - 8 = 72) , also same for $\begin{bmatrix} 0 & a \\[0.3em] 0 & b \\[0.3em] \end{bmatrix}$ and so 72 - 8 = 64 , same for $\begin{bmatrix} a & b \\[0.3em] 0 & 0 \\[0.3em] \end{bmatrix}$
so we have 64 - 8 = 56 and same for $\begin{bmatrix} a & 0 \\[0.3em] b & 0 \\[0.3em] \end{bmatrix}$ so we have 56 - 8 = 48
So we have 48 different matrices in $GL_2(Z_3)$
Now I from those 48 Matrices , I need to find those matrices that have determinant = 1 in $Z_3$ (i.e $ad-bc = 1$ in $Z_3$ but I don't know how to do it.
Any suggestions ?
Here is an easy way.
Let $M \in SL_2(\mathbb Z_3)$ be written as
$$ M = \begin{pmatrix}a & b \\ c & d \end{pmatrix}. $$
First suppose $d=0$. Then $\det M=-bc=1$, so $b=-c$ (remember where the coefficients live). Hence $M$ has the form $$ M = \begin{pmatrix}a & b \\ -b & 0 \end{pmatrix} $$ with $b \neq 0$. There are $6$ such matrices in total.
Now suppose $d \neq 0$. Then since $\det M=ad-bc=1$, we find $a=(1+bc)d$, hence $M$ have the form
$$ M = \begin{pmatrix}(1+bc)d & b \\ c & d \end{pmatrix} $$
There are in total $3\cdot 3 \cdot 2 =18$ such matrices. In total there are $18+6=24$ elements in $SL_2(\mathbb Z_3)$.