Not sure why range criteria is needed here, but give it a try I2:

=COUNTIFS($D$2:$D$5,A2,$E$2:$E$5,B5)