OK, it seems this needs more investigation.
Meanwhile, maybe you can use other function or transformation to replace the `,` with another character and the count.
On the other hand, if you just want to count those headers, probably you can do a while loop to check how many headers are.