Use the Pythagorean theorem.
If x is a hypotenuse, then we have:
[tex]x^2=4^2+5^2\\\\x^2=16+25\\\\x^2=41\to x=\sqrt{41}[/tex]
If x is a leg, then we have:
[tex]x^2+4^2=5^2\\\\x^2+16=25\ \ \ \ |-16\\\\x^2=9\to x=\sqrt9\to x=3[/tex]
Answer: [tex]\sqrt{41}-3[/tex]