Let $F, U$, and $H$ be the events that "the selected coin is fair", "the selected coin is unfair", and "the coin lands heads up", respectively. We are given that
$$
P(F)=\frac{2}{3}, \quad P(U)=\frac{1}{3}, \quad P(H \mid F)=\frac{1}{2}, P(H \mid U)=p .
$$
By Bayes' theorem, the probability that one of the fair coins has been selected given that it lands heads up is
$$
P(F \mid H)=\frac{P(H \mid F) P(F)}{P(H \mid F) P(F)+P(H \mid U) P(U)}=\frac{\frac{1}{2} \times \frac{2}{3}}{\frac{1}{2} \times \frac{2}{3}+p \times \frac{1}{3}}=\frac{1}{1+p} .
$$