Count rows for which certain columns differ

I have a table, where two columns contain similar data. I want to count the number of rows, where these are identical.

I found a solution, but it requires adding an extra row: suppose the two columns to compare are A and B, I add another column C with =(A1 = B1) and so on and can then use =COUNTIF(C1:Cn, "TRUE").
Is it possible to count rows with identical columns without adding such an extra column? I tried using COUNTIFS, but I can’t seem to get the syntax right.

heh… interesting consistency to ask “count rows for which certain columns differ” in title, and then ask how to count those that don’t differ in the body :slight_smile:

oops. I actually need both, so i got it mixed up during writing. I actually checked if my example matched the rest of the text, but forgot the title^^

=SUMPRODUCT(A1:An=B1:Bn)