#K93257. Peak People on the Path

    ID: 38379 Type: Default 1000ms 256MiB

Peak People on the Path

Peak People on the Path

You are given a series of events representing people arriving and departing on a path. Each event is provided as a string in the format <timestamp> <type>, where <timestamp> is an integer representing the time of the event and <type> is a character: 'A' for arrival and 'D' for departure.

Your task is to calculate the maximum number of people on the path simultaneously at any moment during the day. Since the events might not be in chronological order, you must sort them first. Additionally, if two events occur at the same timestamp, arrivals should be processed before departures.

The problem can be mathematically expressed as follows:

$$\text{peak} = \max_{t}\left(\sum_{i=1}^{n} \mathbb{1}_{\{time_i \le t\}} \cdot \delta(event_i)\right)$$

where \(\delta(event_i)=1\) if the event is an arrival ('A') and \(\delta(event_i)=-1\) if it is a departure ('D').

inputFormat

The input is read from stdin. The first line contains a single integer n representing the total number of events. Each of the next n lines contains an event in the format <timestamp> <type>.

outputFormat

Output to stdout a single integer, which is the maximum number of people on the path simultaneously.

## sample
6
1 A
5 A
8 D
10 A
12 D
15 D
2

</p>