Chaotic systems: counting the number of periods