Limits 1s, 512 MB

You are building a new database software: PotatoDB.

PotatoDB is meant to store numbers and handle the following queries:

  • A {N}: Add the number N to the database. Print the total count of numbers stored in the database.

  • D {N}: Delete the number N from the database if it exists. Print the total count of numbers stored in the database.

  • S {X}: Given X, how many numbers have you stored so far whose digits add up to X.

Note that the same number may be stored multiple times in the database and you will have to count each instance of those numbers separately. If the number “100” is added twice, then count them as two numbers.

Input

The input will start with QQ (1Q10001 \le Q \le 1000). QQ is the number of queries that will follow, one per line. The queries will follow the following format:

  • A {N}: The letter “A” followed by NN (109N109-10^9 \le N \le 10^9).

  • D {N}: The letter “D” followed by NN.

  • S {X}: The letter “S” followed by XX (1X1001 \le X \le 100).

Output

For each query, print the response from the database:

  • A {N}: Print the count of numbers in the database after adding the number NN.

  • D {N}: Print the count of numbers in the database after deleting the number NN.

  • S {X}: Print the count of numbers in the database whose digits add up to XX.

Sample

InputOutput
5
A 10
A 10
S 1
D 10
S 2
1
2
2
1
0

Submit

Login to submit.

Statistics

60% Solution Ratio
rifatrraazzEarliest, Dec '22
shz_codeFastest, 0.0s
Anwar.904531Lightest, 4.9 MB
Nusab19Shortest, 201B
Toph uses cookies. By continuing you agree to our Cookie Policy.