HOLES: Getting wa

#include<stdio.h>

int main()
{
	char str[100];
	int i,n,j;
	scanf("%d",&n);
	fflush(stdin);
	int count[n];

	for(i=0;i<n;i++)
	{
		count[i]=0;
		gets(str);
		fflush(stdin);

		for(j=0;str[j]!='\0';j++)
		{
			if(str[j]=='A')    
				count[i]=count[i]+1;

			if(str[j]=='B') 
				count[i]=count[i]+2;   

			if(str[j]=='D') 
				count[i]=count[i]+1;  

			if(str[j]=='R') 
				count[i]=count[i]+1; 

			if(str[j]=='O') 
				count[i]=count[i]+1;

			if(str[j]=='P') 
				count[i]=count[i]+1;

			if(str[j]=='Q') 
				count[i]=count[i]+1;

		}  
	}         
	for(i=0;i<n;i++)
		printf("%d\n",count[i]);



	return 0;
}

Replace gets() with scanf(). Description why this is a problem you can find here.