#include <bits/stdc++.h>

using namespace std;

map<string, int> dict; 
map<string, int> enter;

int main()
{
    //freopen("input.txt", "r" ,stdin);
    int n;
    while (scanf("%d", &n)==1)
    {
        dict.clear();
        enter.clear();
        int m, d, hours, minutes;
        char str[100];
        char flag[100];
        for (int i=1; i<=n; i++)
        {
            scanf("%d/%d", &m, &d);
            scanf("%d:%d", &hours, &minutes);
            scanf("%s%s", flag, str);

            //printf("%d %d %d %d %s %s\n", m, d, hours, minutes, flag, str);
            if (flag[0] == 'I')
            {
                if (string(str) == "000")
                {
                    enter["000"] = hours*60+minutes;
                    for (map<string, int>::iterator ite = enter.begin(); ite!=enter.end(); ite++)
                        if (ite->second!=0)
                            ite->second = hours*60+minutes;
                }
                else
                    enter[string(str)] = hours*60+minutes;
            }
            else
            {
                if (string(str) != "000")
                {
                    if (enter["000"])
                        dict[string(str)] += hours*60+minutes - enter[string(str)];
                    enter[string(str)] = 0;
                }
                else
                {
                    for (map<string, int>::iterator ite = enter.begin(); ite!=enter.end(); ite++)
                    {
                        if (ite->first!="000"&& ite->second!=0)
                        {
                            dict[ite->first] += hours*60+minutes - ite->second;
                            ite->second = hours*60+minutes;
                        }
                    }
                    enter["000"] = 0;
                }
            }
        }
        int ans = 0;
        for (map<string, int>::iterator ite = dict.begin(); ite!=dict.end(); ite++)
        {
            //printf("%s %d\n", ite->first.c_str(), ite->second);
            ans = max(ans, ite->second);
        }
        printf("%d\n", ans);
    }
    return 0;
}