Repeat function


I am looking for the bot to aread how many times it nees to repeat a certain process, once complete then to move on with the next stage of the process.

The above is 2 rows where the bot will type into and then click unhold, however there will be occasions where there maybe 5 rows or 1 row etc. how can i tell the bot to read this and complete the necessary steps.

can anyone help?