There is a grid. Its cells are numbered from left to right. Each cell may be colored or uncolored.
A maximal consecutive interval of colored cells is called a colored component. For a sequence of positive integers
a coloring is valid for if it satisfies all of the following conditions.
- There are exactly colored components.
- When the colored components are ordered from left to right, the size of the -th component is ().
Thus, at least one uncolored cell must lie between every two consecutive colored components. If , the only valid coloring has every cell uncolored.
Initially, the sequence is empty. Process the following queries in order.
1 i X: Let the current length of be . Insert between and . If , insert it at the beginning. If , insert it at the end.2 q: Remove the value that was inserted by query from the current sequence.3 W': Change the width of the grid to .
After each query, find the number of cells that are colored in every valid coloring for the current sequence.
Input
The input is given in the following format.
Each query has one of the following three forms.
Output
After each query, print on its own line the number of cells that are colored in every valid coloring for the current sequence.
Constraints
- .
- .
- .
- .
- In a query
1 i X, if the length of the sequence immediately before the query is , then . - In a query
2 q, , and query is an insertion query whose value has not been removed yet. - After every query, at least one valid coloring exists.