Mirko is playing with stacks. In the beginning of the game, he has an empty stack denoted with number
- a. place number
on top of the new stack - b. remove the number from the top of the new stack
- c. choose another stack denoted with
and count how many different numbers exist that are in the new stack and in the stack denoted with
The newly created stack is denoted with
Mirko doesn't like to work with stacks so he wants you to write a programme that will do it for him. For each operation of type
Input
The first line of input contains the integer
The steps of the game are chronologically denoted with the first
The
a v
for operation of type .b v
for operation of type .c v w
for operation of type .
The first character in the line denotes the type of operation and the following one or two denote the accompanying stack labels that will always be integers from the interval
For each operation of type
Output
For each operation type
Sample Input 1
5
a 0
a 1
b 2
c 2 3
b 4
Sample Output 1
2
1
2
Explanation for Sample Output 1
In the beginning, we have the stack
Sample Input 2
11
a 0
a 1
a 2
a 3
a 2
c 4 5
a 5
a 6
c 8 7
b 8
b 8
Sample Output 2
2
2
8
8
Comments
For future reference, the
and 
c
query is poorly worded, it is asking for the number of distinct numbers that appear in stacksE.g. is
and 
, the answer is 
, because 
appear in both stacks.
Could someone explain the c operation. I'm having a tough time tying together the test data and explanation.
And for the explanation, shouldnt the first set be S0 = {1} instead of S1?