Consider a rectangle ABCD where AB = 8 and BC = 6. A point P lies within the rectangle. The segments AP, BP, CP, and DP represent the distances from point P to the vertices of the rectangle. According to the theorem of geometric means, the following relationship holds:
$$AP^2 + CP^2 = BP^2 + DP^2$$
What is the distance AP if it is given that BP = 5, CP = 3, and DP = 4?