I'm getting in Wrong answer in the Test Case 1 .Please check my code it is alright according to me

I’m getting in Wrong answer in the Test Case 1 .Please check my code it is alright according to me.

debug for this:
5
3
4
5
1
2
2
Correct output:
4
you can watch this too
https://www.youtube.com/watch?v=QOVBnzPgFYY