Given a polynomial $P$ with integer coefficients, find $P(2)$

As mentioned earlier, the sum of all coefficients is $40$, and the first coefficient is $33$. So the sum of the rest of the coefficients is $7$. All we can do is go modulo powers of $9$, since for each $n$ we have $\sum_{k=0}^n a_k9^k \equiv P(9) \mod 9^{n+1}$.

Of this, we go mod $81$ : $60000$ leaves remainder $60$ upon division by $81$. So, $9a_1 + 33$ leaves the same remainder upon division by $81$. This of course gives $a_1 = 3$ by uniqueness.

Next go mod $729$ : $60000$ leaves remainder $222$, so $81a_2 + 60 = 222$ by uniqueness, giving $a_2 = 2$.

Go mod $6561$ : $60000$ leaves remainder $951$, so $222 + 729a_3 = 951$ giving $a_3 = 1$.

Finally $59049$, gives the same remainder , so $a_4 = 0$.

Go modulo $9^6 > 60000$ : this simply gives $a_5 = 1$, since the remainder is $60000$. No more coefficients can be non-zero : they add up to $40$ now.

So the polynomial is $x^5 + x^3 + 2x^2+3x+33$. One checks that the conditions are satisfied and all coefficients are non negative.

Finally the answer is when you substitute $2$ in here : $32+8+8+6+33 = 87$.