14.51. In a drawer, there are red and black socks. If two socks are randomly pulled out of the drawer, the probability that both are red is $1 / 2$.

a) What is the smallest number of socks that can be in the drawer?

b) What is the smallest number of socks that can be in the drawer if it is known that the number of black socks is even?
14.51. a) Answer: 4. Let there be $m$ red socks and $n$ black socks in the box. The probability that the first selected sock is red is $\frac{m}{n+m}$. Given that the first selected sock is red, the probability that the second selected sock is also red is $\frac{m-1}{n+m-1}$. Therefore, the probability that both socks are red is $\frac{m}{n+m} \cdot \frac{m-1}{n+m-1}$. Thus, we need the equality

$$
\frac{m}{n+m} \cdot \frac{m-1}{n+m-1}=\frac{1}{2}
$$

For $n=1$, we get $m=3$. This set of socks suits us.
b) Answer: 21. Clearly, $n>0$. Then, as it is easy to check, $\frac{m}{n+m}>\frac{m-1}{n+m-1}$. Therefore, the inequalities must hold

$$
\left(\frac{m}{n+m}\right)^{2}>\frac{1}{2}>\left(\frac{m-1}{n+m-1}\right)^{2}
$$

i.e., $(\sqrt{2}+1) n<m<(\sqrt{2}+1) n+1$. By the condition, the number $n$ is even. For $n=2,4,6$ we get $m=5,10,15$. In the first two cases, the equality (1) does not hold, but in the third case, it does. In this case, $n+m=6+15=21$.

Remark. Let $x=m-n$ and $y=n$. Then the equality (1) can be rewritten as $(2 x-1)^{2}-2(2 y)^{2}=1$. Therefore, in the general case, we are dealing with a Pell's equation.