How many positive integers less than 10,000 have at most two different digits?

(第二十二届AIME2 2004 第4题)