Adding and counts every shared element twice, so subtract the size of the overlap once: . For three sets, subtract the three pairwise overlaps and add back the triple overlap.
| Step | On , | |
|---|---|---|
| 1 | Find the size of each set. Count the elements of each set once. | , |
| 2 | Find the overlap. List the shared elements. If there are none, the sets are disjoint and you just add.Intersection ↗ | , |
| 3 | Add the sizes and subtract the overlap once. Each shared element was counted once with and once with . | |
| 4 | Check against the union when it is small. List the union directly; the two counts must match.Union ↗ | , |