I have 2 custom objects sharing a master detail realtionship. Object A is the parent, Object B is the child. Object B has a lookup field to Account. I want to create a field on object A that will count the number of unique Object B records based on the account look up field on object A 

e.g. If the following are object B records:

- Acc A
- Acc A
- Acc A
- Acc b

The total number of records should be 2 considering Acc A has been repeated. Any ideas?