Let be any of these described matricies, .

Then (since is odd).

And .

Since via the nonzero trace, clearly , and .

From that it's obvious to identify the given set of usable integers with , the integer remainders modulo p.

Let , and denote the multiplicative inverse of by .

So we want the cardinality of .

But amounts to simply .

Thus .

Thus the function , is surjective.

But looking at the first row shows it's obviously injective. Hence it's bijective.

Hence .

Thus there are disitinct matricies your problem described, exactly one such for each top row made by choosing any values in {1, 2, ..., p-1}.