 Suppose you have two sets A and B. To find the number of elements in A union B, we can add the number of elements in each set. But because there might be elements included in both sets, we need to subtract the number of elements that are in both. This is an example of what's known as the inclusion-exclusion principle. For example, suppose 25 people like chocolate chip cookies, 38 like kale, and 7 like both. How many like chocolate chip cookies or kale? So let's consider our two sets. We'll let C be the set of people who like chocolate chip cookies, and K be our set of people who like kale. Then the number of people who like either chocolate chip cookies or kale will be the number who like chocolate chip cookies, plus the number who like kale. But since this counts to people in the intersection twice, we'll need to subtract out the intersection. So filling our numbers we get. What if we have three sets? It's easiest to see how this will work using a Venn diagram for three sets. So if we draw a generic Venn diagram, we see that the number of elements in all three sets will be the number in the three sets individually. But note that this will count some elements multiple times. So anything that's in the pairwise intersection of sets will be counted twice, and so we'll need to subtract those pairwise intersections. But now consider something that's in the intersection of all three sets. Anything in this intersection would have been counted three times initially, but then we would have subtracted three for each of the intersections, so we need to add it back in to get the correct count. For example, consider a three-digit number. How many include one as the first digit, two as the second digit, or three as the third digit? So we can start off with the numbers that begin with one, and these are the numbers. To count these, we can index them. And since our last digits are changing, we'll go ahead and use the last digit as the index. So 100 last digit zero, well, that's i equals zero. 101 last digit one, that'll be i equals one, and so on. Since i equals zero is our first number, the term number is one more than the index. So our last term i equals 99 will be the one plus 99 100th number. So there are 100 numbers that begin with a one. And as a reminder of a useful principle in math and in life, if it's not written down, it didn't happen. So let's make a record of this. There are 100 numbers of the form one x, y, where x and y are the two remaining digits. The numbers that have two as a second digit are and likewise in every hundred from 100 to 900. And again, to count these, we'll index them. So to count the number in any hundred, we'll index them on that last digit again. So 120, that's our i equals zero. 121, that's our i equals one, and so on. And since i equals zero is our first number, then i equals nine will be the 10th number. And so there are 10 in every hundred. And so there are 10 times 90 numbers with nine as the second digit. The numbers whose third digit is three are and, and again, it follows that there are 10 in every hundred from 100 to 900. So there are 90 numbers with three as a third digit. Now these will count some numbers more than once. So note that some numbers with one as a first digit will have two as a second digit. And these numbers are, and there are 10 such numbers. There are also 10 numbers that have one as a first digit and three as a third digit. And 10 numbers that have two as a second digit and three as a third digit, or are there? So in combinatorial problems, it's useful to list at least three. And again, to count index. And here we can index on our first digit, so our numbers. And since i equals one is our first number, the index is the same as the term number, so i equals nine will be the ninth number. And so there are only nine numbers that have a two as a second digit and a three as a third digit. And finally, there's only one number of the form one as the first, two as the second, and three as the third. So applying the inclusion-exclusion principle, we add the singles, we subtract the doubles, we add the triples, and we get 252 numbers that have a one as their first digit, two as their second, or three as their third.