The first Zagreb index $M_1$ of a graph $G$ is equal to the sum of squares of degrees of the vertices of $G$. Goubko proved that for trees with $n_1$ pendent vertices, $M_1 \geq 9\,n_1-16$. We show how this result can be extended to hold for any connected graph with cyclomatic number $\gamma \geq 0$. In addition, graphs with $n$ vertices, $n_1$ pendent vertices, cyclomatic number $\gamma$, and minimal $M_1$ are characterized. Explicit expressions for minimal $M_1$ are given for $\gamma=0,1,2$, which directly can be extended for $\gamma>2$.