WHY ITS GIVING WRONG ANSWER ..PROBLEM CODE STRBIT

#include<stdio.h>
#include<string.h>
int min(int a,int b)
{
if(a<b)
return(a);
else
return(b);
}
int main()
{
int t;
scanf("%d",&t);
while(t–)
{
int n,i,k,sum=0,ans=0,j,s;
char ar[100005];
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++)
scanf(" %c",&ar[i]);
for(i=1;i<=n;i++)
{
if(ar[i]==‘R’)
{

			ans++;
			j=min(n,(i+k-1));
			sum++;
			s=i;
		break;
		}
	}
	s++;
	for(i=s;i<=n;i++)
	{
		
			if(i<=j)
			{
				if(ar[i]=='G'&&sum%2!=0)
				{
			    ans++;
			    j=min(n,(i+k-1));
			    sum++;
		        }
		    }
		else
		{
	
		   if(ar[i]=='R')
		  {
			
			ans++;
			j=min(n,(i+k-1));
			sum++;
          }
		}
	}
	printf("%d\n",ans);
}

}

//