# Calculate # of shared elements in cells [closed]

I am struggling to get a calc formula to do the following calculations:

```
A B D G H A
A B C 2 1
A D E 2 1
A F G 1 2
B H I 1 1
```

As in the example, I need for the formula to compare two cells, and tell me how many common elements they share -without me stating which elements are there in any of the two cells, although they are always letters from the alphabet, and any given letter is never repeated in the same cell-. Just for clarification, the example is comparing what would be B1 with A2, A3, A4 and A5, and C1 to A2, A3, A4 and A5 respectively.

Any ideas on how to achieve it? Thanks!