27-r to the 3rd power

did you mean (27-r)^3 ?

then you have

27^3 + 3(27)^2 (-r) + 3(27)(-r^2 + (-r)^3
= 19683 - 2187r + 81r^2 - r^3