Let $\displaystyle f(X)$ be a polynomial over $\displaystyle \mathbb{Z}_3$ such that $\displaystyle d(X)=gcd(f(X),f(X)+(X^2+X+1))$ is a polynomial of degree 1. Determine $\displaystyle d(X)$.

Quite literally stumped. I get why $\displaystyle d(X)$ is of degree 1, but I don't know how to determine it at all.