another way is to use the binomial theorem...now, i know what you're thinking...that's a lot of calculation, but:
every term is going to be of the form a(3k)^n. all the terms for n > 2 are going to disappear since (3k)^3 = (27)(k^3) = 0 (mod 27).
so that leaves just the 9k^2, 3k and constant term.
the constant term is going to be 1^9 = 1.
the coefficient of the 3k term is going to be 9, and 9(3k) = 27k = 0 (mod 27).
the coefficient of the (3k)^2 term is going to be 9!/(2!7!) = (8)(9)/2 = 36, and (36)(3k)^2 = (27)(4k^2) = 0 (mod 27),
so only the constant term survives, and that's 1.
In your case
Also note that given that
In our case take note that for each term above the exponent can be expressed as
which, due to the law of exponents is the same as (where k is a non-negative integer)
We also know from our laws of exponents that and so each term which has a term where will be a multiple of 27.
If a number is a multiple of 27 then it is
This means that each term above will be (because they're all multiples of 27) and we're simply adding 0 after the third term.
Therefore we look at our first two terms
You can then take those terms to mod 27 and be left with the constant. Does that make more sense?