Hi Toni,
Let see my screenshot of code.
I'm using a shift register on the while loop.
When the condition is satisfied, it increments the number in the shift register, and if the condition is not satisfied, it's doing nothing.
At the end of the loop, you can recuperate the number incremented in the shift register.
Best regards,
G Liagre