We study the problem of maximizing Betti numbers of simplicial complexes. We prove an upper bound of 1.32n for the sum of Betti numbers of any n-vertex flag complex and 1.25n for the independence complex of a triangle-free graph. These findings imply upper bounds for the Betti numbers of various related classes of spaces, including the neighbourhood complex of a graph. We also make some related observations.