1. Only after he had lost his health did he realize the importance of it.
2. Only after he had lost his health, did he realize the importance of it.
3. Only after he had lost his health, he realized the importance of it.
4. Only after he had lost his health he realized the importance of it.
5. Only after he lost his health did he realize the importance of it.
(Are they all grammatical? Which ones are grammatically correct?)