* Problem:* Consider the set S of all integers between and including 1000 and 99999. Call two integers x and y in S to be in the same equivalence class if the digits appearing in x and y are the same. For example, if x = 1010, y = 1000 and z = 1201, then x and y are in the same equivalence class, but y and z are not. Find the number of distinct equivalence classes that can be formed out of S.

*Any set of distinct digits with maximum order 5 is a equivalence class that can be formed out of S except {0}.*

**Solution:**Number of such sets is

= + + + + -1

= 10 + 45 + 120 + 210 + 252 -1

= 636