Help me in solving LB02B problem

My issue

Could you guyss tell me the logic??

Learning course: Python for problem solving - 1
Problem Link: CodeChef: Practical coding for everyone