The Hanna Neumann conjecture is a statement about the rank of the intersection of two finitely generated subgroups of a free group. The conjecture was posed by Hanna Neumann in 1957. In 2011, a strengthened version of the conjecture was proved independently by Joel Friedman and by Igor Mineyev. In this paper we show that the strengthened Hanna Neumann conjecture holds not only in free groups but also in non-solvable surface groups. In addition, we show that a retract in a free group and in a surface group is inert. This implies the Dicks–Ventura inertia conjecture for free and surface groups.