3 USC § 19. Vacancy in offices of both President and Vice President; officers eligible to act.
(a) (1) If, by reason of death, resignation, removal from office, inability, or failure to qualify, there is neither a President nor Vice President to discharge the powers and duties of the office of President, then the Speaker of the House of Representatives shall, upon his resignation as Speaker and as Representative in Congress, act as President.
(2) The same rule shall apply in the case of the death, resignation, removal from office, or inability of an individual acting as President under this subsection.
(b) If, at the time when under subsection (a) of this section a Speaker is to begin the discharge of the powers and duties of the office of President, there is no Speaker, or the Speaker fails to qualify as Acting President, then the President pro tempore of the Senate shall, upon his resignation as President pro tempore and as Senator, act as President.
(c) An individual acting as President under subsection (a) or subsection (b) of this section shall continue to act until the expiration of the then current Presidential term, except that –
(1) if his discharge of the powers and duties of the office is founded in whole or in part on the failure of both the President-elect and the Vice-President-elect to qualify, then he shall act only until a President or Vice President qualifies; and
(2) if his discharge of the powers and duties of the office is founded in whole or in part on the inability of the President or Vice President, then he shall act only until the removal of the disability of one of such individuals.
(d) (1) If, by reason of death, resignation, removal from office, inability, or failure to qualify, there is no President pro tempore to act as President under subsection (b) of this section, then the officer of the United States who is highest on the following list, and who is not under disability to discharge the powers and duties of the office of President shall act as President: Secretary of State, Secretary of the Treasury, Secretary of Defense, Attorney General, Secretary of the Interior, Secretary of Agriculture, Secretary of Commerce, Secretary of Labor, Secretary of Health and Human Services, Secretary of Housing and Urban Development, Secretary of Transportation, Secretary of Energy, Secretary of Education, Secretary of Veterans Affairs, Secretary of Homeland Security.
(2) An individual acting as President under this subsection shall continue so to do until the expiration of the then current Presidential term, but not after a qualified and prior-entitled individual is able to act, except that the removal of the disability of an individual higher on the list contained in paragraph (1) of this subsection or the ability to qualify on the part of an individual higher on such list shall not terminate his service.
(3) The taking of the oath of office by an individual specified in the list in paragraph (1) of this subsection shall be held to constitute his resignation from the office by virtue of the holding of which he qualifies to act as President.
(e) Subsections (a), (b), and (d) of this section shall apply only to such officers as are eligible to the office of President under the Constitution. Subsection (d) of this section shall apply only to officers appointed, by and with the advice and consent of the Senate, prior to the time of the death, resignation, removal from office, inability, or failure to qualify, of the President pro tempore, and only to officers not under impeachment by the House of Representatives at the time the powers and duties of the office of President devolve upon them.
(f) During the period that any individual acts as President under this section, his compensation shall be at the rate then provided by law in the case of the President.
https://en.wikipedia.org/wiki/Presidential_Succession_Act#After_the_Presidential_Succession_Act_of_1947