Problem 3. The perimeter of triangle $ABC$ is 1. Circle $\omega$ touches side $BC$, the extension of side $AB$ at point $P$, and the extension of side $AC$ at point $Q$. The line passing through the midpoints of $AB$ and $AC$ intersects the circumcircle of triangle $APQ$ at points $X$ and $Y$. Find the length of segment $XY$.

(D. Brodsky)