But as soon as you face two or more conditions which you want to apply with logical AND's or OR's, you are in trouble with COUNTIF.
SUMPRODUCT is your solution here.
Please note that I suggest NOT to take SUMPRODUCT as a holy grail. I use this example just as an evolutionary argument. Please read additional material on SUMPRODUCT here.