#C7018. List Command Processor

    ID: 50843 Type: Default 1000ms 256MiB

List Command Processor

List Command Processor

You are given a sequence of commands to manipulate a list of integers. The commands come in three types:

  • insert x: Append the integer \(x\) to the end of the list.
  • delete x: Remove the first occurrence of the integer \(x\) from the list. If \(x\) is not found, do nothing.
  • query x: Output the number of occurrences of the integer \(x\) in the list.

The program should read the total number of commands from standard input, followed by the commands (one per line). For each query command, the program should print the result on standard output.

Example: For the following sequence of commands:

5
insert 5
insert 3
query 5
delete 5
query 5

The expected output is:

1
0

inputFormat

The first line contains an integer \(n\) representing the number of commands. The following \(n\) lines each contain a command, which can be one of the following forms:

  • insert x
  • delete x
  • query x

Here, \(x\) is an integer.

outputFormat

For each query command in the input, output a single line containing an integer that represents the count of \(x\) in the list at that moment.

## sample
5
insert 5
insert 3
query 5
delete 5
query 5
1

0

</p>