#K91152. List Operation Processor
List Operation Processor
List Operation Processor
You are given a sequence of operations to be performed on an initially empty list. There are three types of operations:
- 1 x: Append the integer x to the end of the list.
- 2 x: Remove the first occurrence of the integer x from the list if it exists.
- 3 x: Count and output the number of occurrences of the integer x currently in the list.
Your task is to simulate the operations and output the result of every type 3 operation. All input must be read from stdin
and the resulting outputs must be printed to stdout
, each on a new line.
Note: When performing a remove operation (type 2), if the element is not in the list, simply ignore the operation.
inputFormat
The first line contains a single integer n --- the number of operations.
Each of the next n lines contains two space-separated integers op and x, where op is the operation type (1, 2, or 3) and x is the integer operand.
outputFormat
For each operation of type 3, output a single line containing the count of x in the list at that moment.
## sample2
1 5
3 5
1
</p>