Help me in solving BUYGAME problem

My issue

can you explain 2nd testcase i am not able to understand why answer is 3 ?

Problem Link: https://www.codechef.com/problems/BUYGAME