I feel like this question will be a head-slapper once I figure out the answer, but for the moment I'm having trouble!
Let $M$ be a compact, connected, orientable 2-manifold of genus $g$ with $b$ boundary components. The Euler characteristic $\chi$ can be expressed as
$\chi = 2 - 2g - b$
and also as
$\chi = H_0 - H_1 + H_2$
where $H_i$ is the rank of the $i$th homology group. Since $M$ is connected we have $H_0 = 1$; since $M$ is a 2-manifold we also have $H_2=1$ (here I'm thinking about de Rham cohomology: $(H_2 = H^0 = \mathrm{ker}\ d_0/\mathrm{im}\ d_{-1} = \mathrm{ker}\ d_0$, which is just the constant functions.). Solving for $H_1$ yields
$H_1 = 2g + b.$
Sounds ok for the most part -- for instance, if $b=0$ then there are twice as many basis loops as handles. But what if, say, $g=0$ and $b=1$, i.e., a disk? Then we have $H_1 = 1$. But every loop in a disk is contractible! Help! (Seems like it should be something like $H_1 = 2g + b-1$ when $M$ has boundary and $H_1 = 2g$ otherwise, but I don't understand why from the arguments above.)