Hi,
Add the default value to the text box using the following steps. So that when the user inserts/deletes the row from the repeating section, it automatically updates the value.
1. Go to the text box properties.
2. Click on fx button beside the Value box.
3. Select the Count function.
4. In that enter the xpath of the repeating section.
The expression should look like
count(/my:myFields/my:group1/my:group2)
here /my:myFields/my:group1/my:group2 is the repeating section xpath.