You can solve the problem in this way

I call A(a,0) the point of the triangle on the x axis, B(0,b) the point on the y axis and M(1,8)

You can find b function of a by finding the equation of (AM)

Then you can find the length of the hypotenuse ABē function of a

To find the minimum you just have to derivate

After calculations I find a=5