Finding the shortest ladder

I was given an analogy involving a ladder that goes over a fence and then leans against a wall a meter after the fence. The question wanted me to answer "what is the shortest ladder that goes over the fence and reaches the wall"

3. The attempt at a solution

I worked out the equation of the "ladder" (i.e line from the ground to the wall) is:

(3sqrt(3) / sin x) + sec x

(where x is the angle the ladder makes with the ground and the wall)

How can i work out the "shortest" ladder that can be made to reach the wall. Is is simply the derivative of the ladder?