BRS cohomology in string theory and the no-ghost theorem