3. The real numbers $x_{1}, x_{2}$, and $x_{3}$ are the three roots of the equation $x^{3}-(p+4) x^{2}+(4 p+5) x-4 p-5=0$, considering their possible multiplicities. Find the smallest value of the expression $\left(x_{1}+1\right)^{2}+\left(x_{2}+1\right)^{2}+\left(x_{3}+1\right)^{2}$ under these conditions. For which $p$ is it realized?
Answer: the minimum value $\frac{257}{16}$ is achieved at $p=-\frac{5}{4}$.