Idempotent matrices

A matrix $M$ is called idempotent if $M^2 = M$.
Let $M$ be a three by three matrix :
$M=\begin{pmatrix}
a & b & c\\
d & e & f\\
g &h &i\\
\end{pmatrix}$.
Let C(n) be the number of idempotent three by three matrices $M$ with integer elements such that
$ -n \le a,b,c,d,e,f,g,h,i \le n$.