#include<stdio.h>
#include<string.h>

int main(void)
{
	int i,run=0,point=0,out=0;
	char s[100];

	scanf("%d",&i);
	while(i!=0)
	{
		scanf("%s",s);
		if(strcmp(s,"HIT")==0)
		{
			run +=1;
			if(run==4)
			{
				run=0;
				point+=1;
			}
		}
		if(strcmp(s,"HOMERUN")==0)
		{
			point+=run+1;
			run=0;
		}
		if(strcmp(s,"OUT")==0)
		{
			out+=1;
			if(out==3)
			{
				run=0;
				out=0;
				printf("%d\n",point);
				point=0;
				i--;
			}
		}	
	}
	return 0;
}