#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

#define in cin
//ifstream in("4475.txt");

struct tarjeta
{
    int hor, min, seg;
    char evento;
};

bool operator < (const tarjeta &t1, const tarjeta &t2)
{
    return t1.hor < t2.hor || t1.hor == t2.hor && (t1.min < t2.min || t1.min == t2.min && t1.seg < t2.seg);
}

inline int maxi(int a, int b)
{
    return (a > b) ? a : b;
}

int main()
{
    int n;
    tarjeta tarjs[64800];

    while (in>>n && n!=0)
    {
        char c;
        int equis = 0;

        for (int i=0; i<n; i++)
        {
            in>>tarjs[i].hor>>c>>tarjs[i].min>>c>>tarjs[i].seg>>tarjs[i].evento;
            if (tarjs[i].evento == 'X')
                equis++;
        }

        sort(tarjs, tarjs+n);

        int cant=0, cantMax=0;

        for (int i=n-1; i>0; i--)
        {
            if (tarjs[i].evento == 'X')
            {
                cantMax = maxi(cantMax, ++cant);
            }
            else if (tarjs[i].evento == 'E')
            {
                cant--;
            }
            else if (tarjs[i].evento == '?')
            {
                if (equis < n/2)
                {
                    equis++;
                    cantMax = maxi(cantMax, ++cant);
                }
                else
                    cant--;
            }
        }

        cout << cantMax << endl;
    }
    return 0;
}

