Generalized count_length, now take all parameters from the command line