AMC 12B 2024 (Problem 21)

The measures of the smallest angles of three different right triangles sum to 90∘90^\circ. All three triangles have side lengths that are primitive Pythagorean triples. Two of them are 3−4−53-4-5 and 5−12−135-12-13. What is the perimeter of the third triangle?
(A)  40\text{(A)}\;40(B)  126\text{(B)}\;126(C)  154\text{(C)}\;154(D)  176\text{(D)}\;176(E)  208\text{(E)}\;208