Im looking for a formula, that would add the values depending on what category they are in.

Colum A has the value and Colum B has the categorys

so like

Value - Cat.
1 - 1
1 - 1
1 - 2
1 - 3
2 - 3
1 - 3
2 - 2

Would give me

Cat1 = 2
Cat2 = 3
Cat 3 = 4