6. (CZS 4) Find the real values of $p$ for which the equation  
$$ \sqrt{2 p+1-x^{2}}+\sqrt{3 x+p+4}=\sqrt{x^{2}+9 x+3 p+9} $$  
in $x$ has exactly two real distinct roots $(\sqrt{t}$ means the positive square root of $t$ ).
6. Setting $q=x^{2}+x-p$, the given equation becomes  
$$ \sqrt{(x+1)^{2}-2 q}+\sqrt{(x+2)^{2}-q}=\sqrt{(2 x+3)^{2}-3 q} . $$  
Taking squares of both sides we get $2 \sqrt{\left((x+1)^{2}-2 q\right)\left((x+2)^{2}-q\right)}=$ $2(x+1)(x+2)$. Taking squares again we get  
$$ q\left(2 q-2(x+2)^{2}-(x+1)^{2}\right)=0 $$  
If $2 q=2(x+2)^{2}+(x+1)^{2}$, at least one of the expressions under the three square roots in (1) is negative, and in that case the square root is not well-defined. Thus, we must have $q=0$. Now (1) is equivalent to $|x+1|+|x+2|=|2 x+3|$, which holds if and only if $x \notin(-2,-1)$. The number of real solutions $x$ of $q=x^{2}+x-p=0$ which are not in the interval $(-2,-1)$ is zero if $p<-1 / 4$, one if $p=-1 / 4$ or $0<p<2$, and two otherwise. Hence, the answer is $-1 / 4<p \leq 0$ or $p \geq 2$.