Help me in solving RED0 problem

My issue

how to solve it any hints or approach?

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