#B4084. Count Unique Solved Problems

    ID: 11741 Type: Default 1000ms 256MiB

Count Unique Solved Problems

Count Unique Solved Problems

In the XCPC contest, a team makes several submissions for each problem. A submission is considered effective if and only if:

  • The team had not solved that problem before this submission, and
  • This submission is a passing submission so that the problem is eventually solved by the team.

Note that even after a problem is solved, further submissions for that problem can be made, but these are considered ineffective and do not affect the solved status.

You are given all submission records of a team in a contest, where there are \(n\) records. Each record is a tuple \((pid_i, state_i)\), where pid_i is the problem identifier and state_i is the submission status which can be either wrong or right (indicating not passed and passed respectively).

Your task is to output the number of distinct problems that the team has eventually solved (i.e. that have at least one effective submission).

Input Constraints:

\(1 \leq n \leq 10^5\). Each pid is a non-negative integer, and state is a string among {wrong, right}.

inputFormat

The first line contains an integer n, the number of submissions. Each of the next n lines contains a problem identifier pid and a submission status state separated by a space. The state is either wrong or right.

outputFormat

Output a single integer denoting the number of distinct problems that were eventually solved by the team.

sample

5
1 right
2 wrong
1 wrong
2 right
3 wrong
2