2. Solve the equation in the set of prime numbers

$$
3 p^{2}+3 p=166+q
$$
Solution. First method. We have $3 p^{2}+3 p=166+q$, i.e., $3 p(p+1)=166+q$. Clearly, $p(p+1)$ is an even number, i.e., $2 \mid p(p+1)$, and since $2 \mid 166$, it follows that $2 \mid q$. But from the condition, $q$ is prime, so we get that $q=2$. Now it easily follows that $p(p+1)=56$, from which $p=7$.

Second method. We have $3 p^{2}+3 p=166+q$, i.e., $3 p(p+1)=166+q$. Clearly, $p(p+1)$ is an even number, i.e., $2 \mid p(p+1)$, and since $2 \mid 166$, it follows that $2 \mid q$.

But from the condition, $q$ is prime, so we get that $q=2$. Now it easily follows that $p(p+1)=56$, from which $p=7$.