Help me in solving STBARR problem

My issue

i’m not getting the logic

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	return 0;
}

Problem Link: STBARR Problem - CodeChef

@sidhantnahak
i’ll give u one hint the maximum answer would be only 2.
so u have to find the cases where u’ll get 0,1,2 as the answers.

Thanks @dpcoder_007 i got the logic. Now i could the the problem.