A fence 2 feet tall runs parallel to a tall building at a distance of 3 feet from the building. What is the length of the shortest ladder that will reach from the ground over the fence to the wall of the building? Help!

if the foot of the ladder is x feet from the wall, and the length of the ladder is z, and the ladder makes an angle θ with the ground,

z/x = secθ
2/(x-3) = tanθ

eliminate θ and find where dz/dx = 0