Question 847384
Password templates that contain a 1:  1####, #1###, ##1##, ###1#, ####1  : 5 different templates.

There are 10^4 ways to fill in the  ####.

So there are 5 * 10^4 ways to have a password with a 1.

Password templates that contain a 2:  1####, #1###, ##1##, ###1#, ####1  : 5 different templates.

There are 10^4 ways to fill in the  ####.

So there are 5 * 10^4 ways to have a password with a 2.

Password templates that contain a 1,2:  12### 21### 1#2## 2#1## 1##2# 2##1# 1###2 2###1 #12## #21##  #1#2# #2#1# #1##2 #2##1 ##12# ##21# ##1#2 ##2#1 ###12 ##21  :  20 templates.

There are 10^3 ways to fill in the ###. This is for each template.

So there are 20*10^3 total ways to have a 1 and 2.

You may be wondering why we counted the case for 1 and 2 when we are looking for 1 or 2 or both.  However, notice that the case of 1 and 2 is in both case 1 as well as case 2. So, our number of ways to count both is counted twice. Thus to compensate we have to subtract the number of ways we can have both once.

Putting this all together:

number of ways to have 1 + number of ways to have 2 - number of ways to have both

5*10^4 + 5*10^4 - 20 * 10^3 = 80000 total numbers.

Food for thought: in comparison there are 10^5 = 100000 possible 5 digit numbers.