Hi Jack,
That is a common feature we implement in our forms. If you need to store the count I would use a formula as a default value, otherwise you can use a calculated value with a default. Here's an example formula:
count(current()/../preceding-sibling::my:group2) + 1
I have also attached a simple example form for reference.
With the use of current() in your formula, just be careful that the function is not deleted I you change your data source. InfoPath has a tendency to take that part out of the formula if your data source changes so you'll sure need to add it back.
Hope that helps!
Bre