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.
The input will start with (). 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 ().
D {N}
: The letter “D” followed by .
S {X}
: The letter “S” followed by ().
For each query, print the response from the database:
A {N}
: Print the count of numbers in the database after adding the number .
D {N}
: Print the count of numbers in the database after deleting the number .
S {X}
: Print the count of numbers in the database whose digits add up to .
Input | Output |
---|---|
5 A 10 A 10 S 1 D 10 S 2 | 1 2 2 1 0 |