Well since there can only be 1 or 2 different digits, let these digits be A and B, and let them be integers between 1 and 9.
We want to fill up the 4 digits spaces with either an A or B, hence there are 2x2x2x2 = 16 ways of arranging the digits.
Now we can choose A in 9 ways, and then B in 8 ways, hence A and B can be chosen in 72 ways.
Therefore since they can be chosen in 72 ways, and arranged in 16 ways, there are 72x16 = 1152 combinations.
Now we consider if 0 is included. 0 can not be the first digit, otherwise it trivially isn't a 4 digit number. So 0 can go in any of the other 3 spots, which can be done in 7 ways:
0 _ _
_ 0 _
_ _ 0
0 0 _
0 _ 0
_ 0 0
0 0 0
And we can place one number of the digits 1 to 9 in the remaining spots, so the amount of ways is 7x9 = 63
Summing the two cases gives:
1152 + 63 = 1215
Now this is N, and we want the sum of the digits of N, so the answer is:
1+2+1+5 = 9.