The triangles are similar meaning that they are scaled up and down differently. ( and in this case rotated) Notice the shape of the triangles. The side measuring 40 in the larger triangle correlates to the side measuring 16 in the smaller triangle. We can use this to find the scale difference between the two triangles. 40/16 = 2.5. The larger triangle is scaled up 2.5 times the smaller triangle. X correlates to the side measuring 14. Scale 14 up 2.5 times. 14* 2.5 = 35, so x= 35.
Y correlates to the side measuring 45. Scale 45 down 2.5 times. 45/2.5 = 18. Y = 18