Hi @utente2
I am little new to AEM forms as well. But based on my understanding, you must be using Designer to create appropriate XDP forms for your use case forms.
In that XDP, you can add XFA scripts. In the script you can add logic to add a counter based on the instance of the title H. And next time H is found you can keep adding a number to it.
Similarly in the XDP we can add JS function as well.
Please add more details on what you may have tried to get more context.
Also this can be a question in AEM Forms community forum.
Regards