#include<iostream>
#include<cstring>
using namespace std;

int main(){
  int n,ansc=0,count=0,count1=0,count2=0,count3=0;
  string event[100];
  cin>>n;
  int i=0;
  while(1){
    cin>>event[i];
    if(event[i]=="OUT"){
      count++;
      count3++;
    }
    if(event[i]=="HIT")count1++;
    if(event[i]=="HOMERUN")count2++;
    if(count3==3*n)break;

    if(count==3){
      count=0;
      count1=0;
      count2=0;
    }
    else if(count2==1){
      ansc+=count1+1;
      count1=0;
      count2=0;
    }
    else if(count1==4){
      ansc++;
      count1--;
    }
    i++;
  }
    cout<<ansc<<endl;
  return 0;
}