Problem:

Range A2:B7 contains the letters A to C and a corresponding number from 0 to 5. Each combination can appear any number of times.
Range D3:D6 contains the letters A to D. The numbers 0 to 5 are listed in cells E2:J2.
We want to create a formula that will count the number of rows in the range A2:B7 containing each letter-number combination shown in the range D2:J6.

Solution:

Use the SUMPRODUCT function as shown in the following formula and enter it in cell E3, then copy the formula to the entire grid (cells E3:J6):
=SUMPRODUCT(($A$2:$A$7=$D3)*($B$2:$B$7=E$2))