Try this in E8:
Formula: copy to clipboard
=COUNTIFS($A$4:$A$13,$D8,$B$4:$B$13,E$7)

Drag down and across

Hope this helps