What is the smallest cube ending in $2017$?
My try: I know that the only possible units digit is $3$,
$$(a+3)^3 = 2017 \mod 10^4\;$$
$$a^3 + 9a^2 + 27a = 1990\mod 10^4$$
I don't know how to proceed, I tried factoring and adding $10^5$ and $1990$ but when I saw the answer, this approach would take forever.