Counting principles (however easy they may be) are not something I'm all that good with.

I am trying to find all 2 x 2 matrices with elements in where p is prime. I'm not going to go into the details but I am breaking the matrices down into subsets and counting them. I have two questions about the counting. ( and are distinct.)

To start with I need a check. For matrices of the following form:

I am counting that there are (p - 1)(p - 2) matrices of the above example. Is that right?

There seems to be (p - 1)(p - 2) matrices of the form

as well. I'm fairly sure I'm right, I just want to check.

My second question is about the matrix:

I need to remove matrices where the determinant ad - bc = 0. How do I count these?

Hopefully I've been clear. Let me know if I'm not.

Thanks!

-Dan