Given: seven-digit numbers using only the digits 0,1,2
leading digit =0
To find: the number of x∈S with at least one of 0,1 appearing exactly twice
i.e. count x with 0 twice, or 1 twice, or both twice
A={x∈S:0 appears exactly twice},B={x∈S:1 appears exactly twice}
∣A∪B∣=∣A∣+∣B∣−∣A∩B∣
Total elements of S=2⋅36=1458
0 twice: choose 2 of the 6 non-leading positions (26)
remaining 5 positions are 1 or 2: 25
∣A∣=(26)⋅25=15⋅32=480
Leading =1: (16)⋅25=6⋅32=192
Leading =2: (26)⋅24=15⋅16=240
∣B∣=192+240=432
Leading =1: (16)⋅(25)=6⋅10=60
Leading =2: (26)⋅(24)=15⋅6=90
∣A∩B∣=60+90=150
∣A∪B∣=480+432−150=762
762