Optional kindergarten education is provided for all children between three and six years old, after which school attendance is compulsory for at least nine years, depending on the state. Primary education usually lasts for four years and public schools are not stratified at this stage. In contrast, secondary education includes three traditional types of schools focused on different levels of academic ability: the "Gymnasium" enrols the most academically promising children and prepares students for university studies; the "Realschule" for intermediate students lasts six years; the "Hauptschule" prepares pupils for vocational education.