Try in O4;
=IF($L$4:$L$9="RCAL",SUMPRODUCT(($A$4:$A$7+$B$4:$B$7>=$I4+$J4)*($A$4:$A$7+$B$4:$B$7<=($I4+$K4+IF($K4-$J4>0,0,1)))*($D$4:$D$7=O$3)*($E$4:$E$7=$Q4)),"")
Column M & N may not be used with this formula, it can be deleted if needed.