For each positive integer n, let S(n) denote the sum of the digits of n. For how many values of n is n+S(n)+S(S(n))=2007?
There are 4 values of n:
n S(n) S(S(n))
1977 24 6
1980 18 9
1983 21 3
2001 3 3