B2 The sides of square $A B C D$ have a length of 6. $M$ is the midpoint of $A B, P$ lies on diagonal $A C$ such that $M P+P B$ is minimized.

Calculate the length of $A P$.

![](https://cdn.mathpix.com/cropped/2024_04_17_3181bece6cd13f041828g-2.jpg?height=299&width=303&top_left_y=313&top_left_x=1476)