#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#define F first
#define S second
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP; //PP(P(SM,SD),PP(P(S_h,S_m),P(E_h,E_m))
typedef pair<P,int> hP;

int main(){
  int n;
  string s,ss,sss,ssss;
  multimap<string,PP> info;
  map<string,hP> index;
  map<string,int> Final;
  while(cin >> n && n){
    info.clear();
    rep(i,n){
      cin >> s >> ss >> sss >> ssss;
      int Mo,Da,st,ed;
      st = ed = 0;
      rep(j,s.length()){ // string to int (Month/Day)
	if(s[j] == '0' && st == 0){
	  st = j+1;
	  continue;
	}     
	if(s[j] == '/'){
	  Mo = (atoi)(s.substr(st,j-st).c_str() );
	  st = j+1;
	}
	else if(j == s.length()-1){
	  Da = (atoi)(s.substr(st,j-st+1).c_str() );
	}
      }// string to int (Month/Day)
 
      st = ed = 0;
      int time_h,time_m;
      rep(j,ss.length() ){ // string to int (time:time)
	if(st == 0 && ss[0] == '0'){
	  st = j+1;
	  continue;
	}
	if(ss[j] == ':'){
	  time_h = (atoi)(ss.substr(st,j-st).c_str() );
	  st = j+1;
	}
	else if(j == ss.length()-1 ){
	  time_m = (atoi)(ss.substr(st,j-st+1).c_str() );
	}
      }// string to int (time:time)
      if(sss == "I"){
	index[ssss] = hP(P(Mo,Da),time_h*60+time_m);
	//cout << index[ssss].F.F << endl;
      }
      else if(sss == "O"){
	info.insert(multimap<string,PP>::value_type(ssss,PP(P(index[ssss].F),P(index[ssss].S,time_h*60+time_m ) )) );
	//map<string,PP>::iterator it = index[ssss];
	index.erase(ssss);
      }
    
    }
    multimap<string,PP>::iterator it = info.begin();
   
    /*    
    while(it != info.end() ){
      cout << "index = " << (*it).F << ", start Month & Day = (" << (*it).S.F.F.F << "," << (*it).S.F.F.S << ") , end Month & Day = (" <<  (*it).S.F.S.F << "," << (*it).S.F.S.S << ") , start time = (" << (*it).S.S.F.F << "," << (*it).S.S.F.S << "), endtime = (" << (*it).S.S.S.F << "," << (*it).S.S.S.S << ")" << endl;  
      it++;
    }
    */

    Final.clear();

    while((*it).F == "000"){   
      //cout << (*it).F << "  "  << (*it).S.F.F << "/" << (*it).S.F.S << ", " << (*it).S.S.F << " 〜 " << (*it).S.S.S << endl;
      multimap<string,PP>::iterator it2 = info.begin();
      while(it2 != info.end() ){
	if((*it2).F == "000"){
	  it2++;
	  continue;
	}
	//cout << (*it2).F << "   "  << (*it2).S.F.F << "//" << (*it2).S.F.S << ", " << (*it2).S.S.F << " 〜 " << (*it2).S.S.S << endl;
	if( (*it).S.F.F == (*it2).S.F.F && (*it).S.F.S == (*it2).S.F.S && ( ( ((*it).S.S.F <= (*it2).S.S.F && (*it2).S.S.F <= (*it).S.S.S  )   ||        ( (*it).S.S.F <= (*it2).S.S.S && (*it2).S.S.S <= (*it).S.S.S  )   )  || ( ((*it2).S.S.F <= (*it).S.S.F  ) && ((*it).S.S.S <= (*it2).S.S.S )  )   )  ){

	  if( ( ((*it2).S.S.F <= (*it).S.S.F  ) && ((*it).S.S.S <= (*it2).S.S.S )  ) ){
	    Final[(*it2).F] += (*it).S.S.S - (*it).S.S.F;
	    //cout << "P_0 Index is " << (*it2).F  << "!! this value is " << Final[(*it2).F] << endl;
	  }
	 else if( ( ((*it).S.S.F <= (*it2).S.S.F && (*it2).S.S.F <= (*it).S.S.S  )     &&    ( (*it).S.S.F <= (*it2).S.S.S && (*it2).S.S.S <= (*it).S.S.S  )   )  ){
	    Final[(*it2).F] += (*it2).S.S.S - (*it2).S.S.F;
	    //cout << "P_1 Index is " << (*it2).F  << "!! this value is " << Final[(*it2).F] << endl;
	  } 
	  else if( ((*it).S.S.F <= (*it2).S.S.F && (*it2).S.S.F <= (*it).S.S.S  )  ){
	    Final[(*it2).F] += (*it).S.S.S - (*it2).S.S.F;
	    //cout << "P_2 Index is " << (*it2).F  << "!! this value is " << Final[(*it2).F] << endl;
	  }
	  else if( ( (*it).S.S.F <= (*it2).S.S.S && (*it2).S.S.S <= (*it).S.S.S  ) ){
	    Final[(*it2).F] += (*it2).S.S.S - (*it).S.S.F; 
	    //cout << "P_3 Index is " << (*it2).F  << "!! this value is " << Final[(*it2).F] << endl;
	  }



	}

	it2++;
      }


      it++;
    }



    int ans = 0;
    map<string,int>::iterator IT = Final.begin();
    while(IT != Final.end() ){
      ans = max(ans,(*IT).S);
      IT++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1292