Let $P(x)$ be a polynomial with rational coefficients such that when $P(x)$ is divided by the polynomial $x^2 + x + 1$, the remainder is $x + 2$, and when $P(x)$ is divided by the polynomial $x^2 + 1$, the remainder is $2x + 1$. There is a unique polynomial of least degree with these two properties. Find the sum of the squares of the coefficients of that polynomial.

Let's think step by step and output the final answer within \boxed{}.
user