Let A = "0 appears exactly twice" and B = "1 appears exactly twice". The first digit is 1 or 2.
∣A∣. Put the two 0s in the last 6 places (6C2=15 ways). The other 5 digits, including the first, are 1 or 2 (25 ways):
∣A∣=15⋅32=480.
∣B∣.
- First digit 1: one more 1 in the last 6 (6 ways), the rest from {0,2} (25): 192.
- First digit 2: two 1s in the last 6 (15 ways), the rest from {0,2} (24): 240.
- Total: 432.
∣A∩B∣.
- First digit 1: the last 6 hold one 1, two 0s and three 2s: 1!2!3!6!=60.
- First digit 2: the last 6 hold two 1s, two 0s and two 2s: 2!2!2!6!=90.
- Total: 150.
∣A∪B∣=480+432−150=762.