For a positive integer $n$,$S(n)$ is the sum of digits. How many positive integers $n$ satisfy $n+S(n)=2008$?
First of all I've written the following relation $n=S(n)+9k,\; k\in\mathbb{Z}$ since we know that $n\equiv S(n)\pmod{9\text{ or }3}$
Then I got that $S(n)\equiv 5\pmod{9}$. I was fine till and my book was open in front of me, and in the solution below there was $S(n)<28$ and $1980<n<2008$ the second one follows after the first one, but I didn't understand really how we got to $S(n)<28$
Well since $n$ is 4 digit number $< 2008$ we have $$S(n) \leq 1+9+9+9=28$$ so $n\geq 2008-28 =1980$
So, since $2n\equiv _9 2n-9k = 2008\equiv _9 1$ we have $n \equiv _9 5$ so $n=9l+5$ thus $n\in \{1985,1994,2003\}=:M$