Excel expert required - Help please

I'm clearly asking google the wrong question and can't get my head round this:

I have 2 columns of data, one contains integers between 0 and 4 and the other contains X or blank, something like this:

__A__ __B__

0 x

1 x

2

4

0 x

3

1 x

0

What I want to do is count how many X there are in column B if the value in the column A is 1

(So here IF column A =0, there are 2 X in Column B and so the answer is 2)

Can it be done using excel functions, without hidden columns and without writing a macro?