The 25th Amendment reiterates what is stated in Article 2, Section 1: that the Vice President is the direct successor of the President. He or she will become President if the President cannot serve for whatever reason. The 25th also provides for a President who is temporarily disabled, such as if the President has a surgical procedure or if he or she become mentally unstable.
The original Constitution provides that if neither the President nor Vice President can serve, the Congress shall provide law stating who is next in line. Currently that law exists as 3 USC 19, a section of the U.S. Code. This law was established as part of the Presidential Succession Act of 1947. There, the following line of succession is provided:
Speaker of the House of Representatives
President Pro Tempore of the Senate
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 (not yet set by law)
The only exception to the line provided in the law states that to ascend to the Presidency, the next person in line must be constitutionally eligible. Any person holding an office in the line of succession who, for example, is not a naturally-born citizen cannot become President. In this case, that person would be skipped and the next eligible person in the line would become President.
http://www.usconstitution.net/consttop_succ.htmlPlease note, you do not count The President in the line of succession! So the Speaker of the House would be 2nd in this line, not third.