A sequential pruning strategy for the selection of the number of states in hidden Markov models