Implementing count_wild_and_variable_lengths function