Count the number of occurrence in Excel

How to count the number of occurrence of values in a column?

For example we have a list of towns in the A column. Among this towns, some are alone, others are in collectivity groups (towns groups, agglomeration communities), that we put in column B.

So, we have n towns, and n-x collectivities. We know our n (=3000) but we would like to know our (n-x).

What is the good formula ?

Here is a suggestion :

=NBVAL(A:A)-NBVAL(B:B)