Dinner Hall

No attempts yetTime limit1sMemory limit128 MB

Problem

The university administration plans to build a new dinner hall to replace the several small and rather inadequate dinner halls spread across the campus. To estimate the number of seats the new hall will need, they ran an experiment to measure the maximum number of clients who were inside the existing dinner halls at the same time.

For the experiment they hired several students as pollers and stationed one at each entrance and each exit of the existing halls. Each poller's job was to record, on a small card, the time of every client who entered or left a hall (one card per event). On each card they wrote the time in the format HH:MM:SS together with the event: the letter 'E' for an entry and the letter 'X' for an exit.

The experiment began early in the morning, before breakfast, and ended late in the evening, after dinner. All the pollers' watches were synchronized, and the halls were empty both before and after the experiment (that is, no client was inside a hall before it began, and no client remained after it ended). The pollers wrote exactly one card for each client who entered a hall and for each client who left a hall.

After the experiment the cards were collected and sent to the administration for processing, but this turned out to be harder than expected, because of two problems. First, the cards were bundled together in no particular order and had to be sorted; sorting is easy but tedious to do by hand. Worse, although every card had a valid time, some pollers forgot to write the letter that identifies the event.

Given the time and event indication of each card (the event indication may be missing), write a program to determine the maximum number of clients that could have been inside the dinner halls at a single instant.

Input

The input contains several test cases. The first line of a test case contains one integer $N$, the number of cards collected in the experiment ($2 \le N \le 64800$). Each of the next $N$ lines contains the information written on one card: a time specification, followed by a single space, followed by an event specification. A time specification has the format HH:MM:SS, where HH is the hour ($06 \le HH \le 23$), MM the minutes ($00 \le MM \le 59$) and SS the seconds ($00 \le SS \le 59$). Within a test case, no two cards share the same time. An event specification is a single character: uppercase 'E' for an entry, uppercase 'X' for an exit, and '?' when the event is unknown. Information may be missing, but the information that is given is always correct: every time is valid, and if a card indicates an entry then a client did enter a hall at that time, if it indicates an exit then a client did leave at that time, and if it indicates an unknown event then a client either entered or left a hall at that time.

The last test case is followed by a line containing a single zero.

Output

For each test case, print a single line containing one integer: the maximum total number of clients that could have been inside the dinner halls at a single instant.