import std.stdio;
import std.algorithm;

void main(){
	while(true){
		int n;
		readf("%d\n", &n);
		if(n == 0) break;
		int[999] itime;
		bool[999] islogin;
		itime[] = 0;
		islogin[] = false;
		int month=-1, date=-1;
		bool logined = false;
		int start;
		while(n--){
			int m, d, hour, minute, p;
			int time;
			char e;
			readf("%d/%d %d:%d %s %d\n", &m, &d, &hour, &minute, &e, &p);
			time = 60*hour+minute;
			if(d != date || m != month){
				if(logined){
					foreach(i, b; islogin)
						if(b) itime[i] += 24*60-start;
				}
				logined = false;
				date = d; month = m;
				islogin[] = false;
			}
			if(e == 'I'){
				if(p == 0){
					logined = true;
					start = time;
					foreach(i, b; islogin)
						if(b) itime[i] -= time-start;
				}else{
					islogin[p-1] = true;
					if(logined)	itime[p-1] -= time-start;
				}
			}else{
				if(p == 0){
					logined = false;
					foreach(i, b; islogin)
						if(b) itime[i] += time - start;
				}else{
					islogin[p-1] =  false;
					if(logined)	itime[p-1] += time-start;
				}
			}
		}
		int m = 0;
		foreach(i; itime) m = max(m, i);
		writeln(m);
	}
}