Approximation by subgroups of finite index and the Hanna Neumann conjecture