This is not a related rates problem is an optimization one.
Sketch the figure and try using similar triangles.
im having trouble solving this problem in my review packet:
An 8 foot high fence is located 1 foot from a building. determine the length of the shortest ladder with its foot on the ground which can be leaned against the building and touch the top of the fence.