How to count the number of subforms?

Hi everyone!

We are working away in ODK survey using the wonderful subforms feature. Our survey has lots of subforms. For example, we initially collect household level data and then have subforms for each member. Each female member who ever gave birth then has a subform for each birth.

Our current question is how to count the number of responses in a subform in order to either generate a variable that is the number of responses and use the number of responses in a constraint/validation. Example: In q8203 we ask the number of live births. Then we have a subform that asks for the name of each birth and a bunch of information in q8204-q8212. So q8204-q8212 repeat, once (one subform) for each birth. After the subforms are filled out, we want to validate that the number of subforms is equal to q8203 (no births were forgotten and q8203 is correct). How can we calculate a variable that’s the number of subforms (which then we can constrain to be equal to q8203)? While we have successfully linked our subforms to their various parent forms, we just have no idea how to count them. Open to other approaches to achieve the same ends too. Or if anyone has resources/examples for cross-referencing subforms in general that would also be amazing.

Thanks much!