Excel Function help



I am looking to find a function to do the following:

1) Compare each row in Columns A and B
2) If any numbers in A and B are the same,
3) Add those numbers from column B.

Example:

A B

5 9
1 1
3 2
4 4

Answer: 5

Any help would be appreciated.

.