  Theories with higher order time derivatives generically suffer from
ghost-like instabilities, known as Ostrogradski instabilities. This fate can be
avoided by considering "degenerate" Lagrangians, whose kinetic matrix cannot be
inverted, thus leading to constraints between canonical variables and a reduced
number of physical degrees of freedom. In this work, we derive in a systematic
way the degeneracy conditions for scalar-tensor theories that depend
quadratically on second order derivatives of a scalar field. We thus obtain a
classification of all degenerate theories within this class of scalar-tensor
theories. The quartic Horndeski Lagrangian and its extension beyond Horndeski
belong to these degenerate cases. We also identify new families of
scalar-tensor theories with the intriguing property that they are degenerate
despite the nondegeneracy of the purely scalar part of their Lagrangian.
