Red giants are evolved stars that have exhausted the supply of hydrogen in their cores and instead burn hydrogen in a surrounding shell. Once a red giant is sufficiently evolved, the helium in the core also undergoes fusion. Outstanding issues in our understanding of red giants include uncertainties in the amount of mass lost at the surface before helium ignition and the amount of internal mixing from rotation and other processes. Progress is hampered by our inability to distinguish between red giants burning helium in the core and those still only burning hydrogen in a shell. Asteroseismology offers a way forward, being a powerful tool for probing the internal structures of stars using their natural oscillation frequencies. Here we report observations of gravity-mode period spacings in red giants that permit a distinction between evolutionary stages to be made. We use high-precision photometry obtained by the Kepler spacecraft over more than a year to measure oscillations in several hundred red giants. We find many stars whose dipole modes show sequences with approximately regular period spacings. These stars fall into two clear groups, allowing us to distinguish unambiguously between hydrogen-shell-burning stars (period spacing mostly ~50seconds) and those that are also burning helium (period spacing ~100 to 300 seconds).