Not Getting right answer

Sir, this concept was also i n tutorial videos. I finished the code for this question but when I was not getting the right answer, I matched with tutorial video, it is same as per my understanding. Please debug it.

If we input the Example shown above, we get 21 printed 2 times and β€˜END’ is not printing.