In H2

=COUNTIF(A:A,INDEX(D:D,MATCH(G2,E:E,0)))

copy down