#C2641. Counting Unended Processes

    ID: 45980 Type: Default 1000ms 256MiB

Counting Unended Processes

Counting Unended Processes

You are given a sequence of events representing the start and end of processes. Each event is a string that begins with either START or END, followed by a process identifier. A START event indicates that a process has begun, and an END event indicates that a process has terminated. Your task is to determine how many processes were started and have not ended by the end of the event list.

Note: If an END event is encountered for a process that was never started, it should be ignored.

The problem can be formalized using the following equation:

\( \text{unended} = |\{ \text{process i : event = START} \}| - |\{ \text{process i : corresponding END event exists} \}| \)

You need to read the input from standard input (stdin) and output the result to standard output (stdout).

inputFormat

The first line of input contains a single integer n which denotes the number of events. The following n lines each contain a string representing an event. Each event is either in the format START<ID> or END<ID>, where <ID> is the unique process identifier.

outputFormat

Output a single integer which is the number of processes that have started but not ended. The output should be printed to stdout.

## sample
5
START1
START2
END1
START3
END3
1