Generalised inclusion-exclusion principle
This is Corollary 5.2 on p. 184 of Martin Aigner's excellent book A Course in Enumeration.
Another reference is section IV.3, "The Realization of m Among N Events", in An Introduction to Probability Theory and Its Applications, Volume I, Third Edition by William Feller, p. 106.