If L is the length of the side of the cube, and x is the distance from the next corner where ant reaches before climbing the vertical face, then the total distance crawled by the ant is

Now find the derivative of D with respect to x and equate it to zero.