When you enter the United States on a student visa, you will usually be admitted for the duration of your student status. That means you may stay as long as you are a full-time student, even if the F-1 visa in your passport expires while you are in America. All student applicants must have a Student and Exchange Visitor Program (SEVP) generated I-20 issued by an educational institution approved by Department of Homeland Security (DHS). For a student who has completed the course of studies shown on the I-20, and any authorized practical training, the student is allowed the following additional time in the U.S. before departure:

F-1 student: An additional 60 days, to prepare for departure from the U.S. or to transfer to another school.
M-1 student: An additional 30 days to depart the U.S. The 30 days to prepare for departure is permitted as long as the student maintained a full course of study and maintained status. An M student may receive extensions up to 3 years for the total program.