Cheongrin joined DOJ to improve her problem-solving skills and started solving problems recommended by her friends.
DOJ has a tag system for classifying problems. Each problem has zero or more tags among possible tags.
Cheongrin represents a tag list as a bit string of length . For a bit string , if the -th character from the left, , is , then the tag list contains tag ; otherwise it does not contain tag . If a problem has tag list , then it has exactly the tags represented by .
Cheongrin does not solve recommended problems immediately. Instead, she stores them in a list of problems to solve later. Initially, this list is empty. Process the following queries.
1 S x: Add problems with tag list to the list.2 S x: Remove problems with tag list from the list. It is guaranteed that at least such problems are currently in the list.3 S: Print the number of problems currently in the list that contain every tag contained in tag list .
For a type query, a counted problem only needs to contain all tags contained in . That is, for every with , the problem must also have tag ; tags with do not matter.
Input
The input is given in the following format.
Each () is given in one of the following formats: 1 S x, 2 S x, or 3 S.
Output
For each query of the form 3 S, print the number of problems satisfying the condition on a separate line.
Constraints
- .
- .
- In every query, is a bit string of length .
- In queries of the form
1 S xand2 S x, . - Whenever a query
2 S xis given, at least problems with tag list are currently in the list.
Subtasks
Samples
After the first two queries, the list contains problems with tag list 101 and problems with tag list 111. Therefore, the answer to 3 101 is .
After removing one 101 problem, one 101 problem and three 111 problems remain. The answer to 3 001 is .
Finally, after adding four 010 problems, the total number of problems is , so the answer to 3 000 is .