Stellar activity can induce signals in the radial velocities of stars, complicating the detection of orbiting low-mass planets. We present a method to determine the number of planetary signals present in radial-velocity datasets of active stars, using only radial-velocity observations. Instead of considering separate fits with different number of planets, we use a birth-death Markov chain Monte Carlo algorithm to infer the posterior distribution for the number of planets in a single run. In a natural way, the marginal distributions for the orbital parameters of all planets are also inferred. This method is applied to HARPS data of CoRoT-7. We confidently recover both CoRoT-7b and CoRoT-7c although the data show evidence for additional signals.