For any two finite sets A and B: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣, where ∣A∣, ∣B∣, ∣A∩B∣, ∣A∪B∣ denote the number of elements of each set.
Why is it true?
Simply adding ∣A∣ and ∣B∣ double-counts every element that is in both sets, so subtracting ∣A∩B∣ once corrects the overcount. This is exactly the arithmetic behind reading a two-circle Venn diagram from survey data: people who like both coffee and tea must not be counted twice when asking how many people like at least one.
Proof sketch
The key idea is to split A∪B into three pairwise-disjoint pieces and count each piece once.
First, partition each set using the other: A=(A∖B)∪(A∩B) and B=(B∖A)∪(A∩B). In each equation the two pieces on the right are disjoint, because (A∖B)∩(A∩B)=∅ (an element outside B cannot simultaneously be inside B) and likewise (B∖A)∩(A∩B)=∅. Since a finite set's size equals the sum of the sizes of any partition into disjoint pieces, this gives ∣A∣=∣A∖B∣+∣A∩B∣ and ∣B∣=∣B∖A∣+∣A∩B∣.
Next, observe that A∪B itself splits into three pairwise-disjoint pieces: A∪B=(A∖B)∪(B∖A)∪(A∩B). Indeed A∖B, B∖A, A∩B are pairwise disjoint (an element in A∖B is not in B, hence not in A∩B or in B∖A; symmetrically for the others), and their union recovers exactly the elements that are in A or in B. Counting this partition gives ∣A∪B∣=∣A∖B∣+∣B∖A∣+∣A∩B∣.
Finally substitute: from ∣A∣=∣A∖B∣+∣A∩B∣ we get ∣A∖B∣=∣A∣−∣A∩B∣, and from ∣B∣=∣B∖A∣+∣A∩B∣ we get ∣B∖A∣=∣B∣−∣A∩B∣. Plugging both into ∣A∪B∣=∣A∖B∣+∣B∖A∣+∣A∩B∣ gives ∣A∪B∣=(∣A∣−∣A∩B∣)+(∣B∣−∣A∩B∣)+∣A∩B∣=∣A∣+∣B∣−∣A∩B∣, which is exactly ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣. This finishes the proof.