Another approach without helper columns:
=COUNTIFS($E$2:$E$7,E2,$F$2:$F$7,F2)+COUNTIFS($E$2:$E$7,F2,$F$2:$F$7,E2)
Result: