#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

int toi(string s){
    int ret = 0;
    rep(i,s.size()){
        ret *= 10;
        ret += s[i]-'0';
    }
    return ret;
}

#define M 60*24+3

int main(void) {
    int i,j;
    int n;
    int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    rep(i,12)days[i+1] += days[i];
    while(cin >> n, n){
        vector<vector<vp> > v(365,vector<vp>(1000));
        rep(i,n){
            string a,b,io,id;
            cin >> a >> b >> io >> id;
            int day = days[toi(a.substr(0,2))-1] + toi(a.substr(3,2));
            int t = toi(b.substr(0,2))*60 + toi(b.substr(3,2));
            v[day][toi(id)].push_back(pii(t,int(io=="O")));
        }
        vi sum(1000,0);
        rep(i,365){
            int god[M] = {};
            rep(k,v[i][0].size()){
                if(v[i][0][k].second) god[v[i][0][k].first]--;
                else god[v[i][0][k].first]++;
            }
            rep(k,M-1)god[k+1] += god[k];
            loop(j,1,1000)if(v[i][j].size()){
                int t[M] = {};
                rep(k,v[i][j].size()){
                    if(v[i][j][k].second) t[v[i][j][k].first]--;
                    else t[v[i][j][k].first]++;
                }
                rep(k,M-1)t[k+1] += t[k];
                rep(k,M)if(god[k]&&t[k])sum[j]++;
            }
        }
        sort(all(sum));
        cout << sum[999] << endl;
    }
}

