Hamiltonian analysis of higher derivative scalar-tensor theories