#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */


// quoted from beet-aizu
template <typename T, typename E, typename F, typename G>
struct SegmentTree{
    // using F = function<T(T, T)>
    // using G = function<T(T, E)>
    int n;
    F f;
    G g;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,G g,T ti):f(f),g(g),ti(ti){}
    void init(int n_){    
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void update(int k,const E &x){
        k += n;
        dat[k] = g(dat[k], x);
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
    }
    T operator [](int k) const { return dat[k+n]; }
    T query(int a,int b) const {
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

    /* TODO わからない 聞く 
    template<typename C>
    int find(int a,int b,C &check,int k,int l,int r){
        if(!check(dat[k])||r<=a||b<=l) return -1;
        if(k>=n) return k-n;
        int m=(l+r)>>1;
        int vl=find(a,b,check,(k<<1)|0,l,m);
        if(~vl) return vl;
        return find(a,b,check,(k<<1)|1,m,r);
    }
    template<typename C>
    int find(int a,int b,C &check){
        return find(a,b,check,1,0,n);
    }*/
    
};


/**  テンプレ
int main(){
**/

bool solve() {
  int n; cin >> n;
  if(n == 0) return false;
  vector<int> id(n);
  vector<int> t(n);
  vector<char> mode(n);
  
  for(int i = 0; i < n; i++) {
    string a, b, c, ID; cin >> a >> b >> c >> ID;
    // cerr << a.substr(3, 2) << " " << b.substr(0, 2) << " " << b.substr(3, 2) << endl;
    int M = stoi(a.substr(0, 2));
    int d = stoi(a.substr(3, 2));
    int h = stoi(b.substr(0, 2));
    int m = stoi(b.substr(3, 2));
    assert(M <= 12);
    assert(d <= 31);
    assert(h <= 24);
    assert(m <= 60);

    t[i] = M * 32 * 24 * 60 + d * 24 * 60 + h * 60 + m;
    id[i] = stoi(ID);
    mode[i] = c[0];
  }

  vector<vector<int>> l(1000);
  vector<vector<int>> r(1000);

  for(int i = 0; i < n; i++) {
    if(mode[i] == 'I') {
      l[id[i]].push_back(t[i]);
    } else {
      r[id[i]].push_back(t[i]);
    }
  }
  
  vector<int> dat(13 * 32 * 25 * 61, 0);
  
  assert(l[0].size() == r[0].size());
  for(int j = 0; j < l[0].size(); j++) {
    int left = l[0][j];
    int right = r[0][j];
    for(int i = left; i < right; i++) dat[i] = 1;
  }

  using T = int;  // type T
  using E = int;  // type E
  auto f = [](T a, T b){ // return type T value
    return a + b;
  };
  auto g = [](T a, E b){ // return type T value
    return b;  // return b;
  };
  T ti = 0;  // identify element
  SegmentTree<T, E, decltype(f), decltype(g)> sg(f, g, ti);  // don't change
  sg.build(dat);   // 初期配列を代入
  
  vector<int> cnt(1000, 0);
  for(int i = 1; i < 1000; i++) {
    assert(l[i].size() == r[i].size());
    for(int j = 0; j < l[i].size(); j++) {
      int left = l[i][j];
      int right = r[i][j];
      cnt[i] += sg.query(left, right);
    }
  }

  int ma = 0;
  for(int i = 0; i < 1000; i++) ma = max(ma, cnt[i]);
  cout << ma << endl;
  
  return true;
}

signed main() {
  
  while(solve()) {}
  return 0;
}



Measured memory_bytes: 13800