Okabe and Super Hacker Daru are stacking and removing boxes. There are _n_ boxes numbered from 1 to _n_. Initially there are no boxes on the stack.
Okabe, being a control freak, gives Daru 2_n_ commands: _n_ of which are to add a box to the top of the stack, and _n_ of which are to remove a box from the top of the stack and throw it in the trash. Okabe wants Daru to throw away the boxes in the order from 1 to _n_. Of course, this means that it might be impossible for Daru to perform some of Okabe's _remove_ commands, because the required box is not on the top of the stack.
That's why Daru can decide to wait until Okabe looks away and then reorder the boxes in the stack in any way he wants. He can do it at any point of time between Okabe's commands, but he can't add or remove boxes while he does it.
Tell Daru the minimum number of times he needs to reorder the boxes so that he can successfully complete all of Okabe's commands. It is guaranteed that every box is added before it is required to be removed.
## Input
The first line of input contains the integer _n_ (1 ≤ _n_ ≤ 3·105) — the number of boxes.
Each of the next 2_n_ lines of input starts with a string "_add_" or "_remove_". If the line starts with the "_add_", an integer _x_ (1 ≤ _x_ ≤ _n_) follows, indicating that Daru should add the box with number _x_ to the top of the stack.
It is guaranteed that exactly _n_ lines contain "_add_" operations, all the boxes added are distinct, and _n_ lines contain "_remove_" operations. It is also guaranteed that a box is always added before it is required to be removed.
## Output
Print the minimum number of times Daru needs to reorder the boxes to successfully complete all of Okabe's commands.
[samples]
## Note
In the first sample, Daru should reorder the boxes after adding box 3 to the stack.
In the second sample, Daru should reorder the boxes after adding box 4 and box 7 to the stack.
Okabe 和超级黑客 Daru 正在堆叠和移除盒子。有 #cf_span[n] 个编号从 #cf_span[1] 到 #cf_span[n] 的盒子。最初栈中没有盒子。
Okabe 作为一个控制狂,给了 Daru #cf_span[2n] 个指令:其中 #cf_span[n] 个是将一个盒子放到栈顶,另外 #cf_span[n] 个是从栈顶移除一个盒子并扔进垃圾桶。Okabe 希望 Daru 按照从 #cf_span[1] 到 #cf_span[n] 的顺序扔掉盒子。当然,这意味着在某些时刻,Daru 可能无法执行某些 _remove_ 指令,因为所需的盒子并不在栈顶。
因此,Daru 可以选择在 Okabe 不注意时,随时对栈中的盒子重新排序。他可以在 Okabe 的任意两条指令之间进行重排,但在重排过程中不能添加或移除盒子。
请告诉 Daru,他最少需要重新排序多少次,才能成功完成所有 Okabe 的指令。保证每个盒子在被要求移除之前都会被添加。
输入的第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 3·105]) —— 盒子的数量。
接下来的 #cf_span[2n] 行中,每行以字符串 "_add_" 或 "_remove_" 开头。如果行以 "_add_" 开头,则后面跟着一个整数 #cf_span[x] (#cf_span[1 ≤ x ≤ n]),表示 Daru 应该将编号为 #cf_span[x] 的盒子添加到栈顶。
保证恰好有 #cf_span[n] 行包含 "_add_" 操作,所有添加的盒子互不相同,且有 #cf_span[n] 行包含 "_remove_" 操作。同时保证每个盒子总是在被要求移除之前被添加。
请输出 Daru 成功完成所有 Okabe 指令所需的最少重新排序次数。
在第一个样例中,Daru 应该在将盒子 #cf_span[3] 添加到栈后重新排序。
在第二个样例中,Daru 应该在将盒子 #cf_span[4] 和盒子 #cf_span[7] 添加到栈后分别重新排序。
## Input
输入的第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 3·105]) —— 盒子的数量。接下来的 #cf_span[2n] 行中,每行以字符串 "_add_" 或 "_remove_" 开头。如果行以 "_add_" 开头,则后面跟着一个整数 #cf_span[x] (#cf_span[1 ≤ x ≤ n]),表示 Daru 应该将编号为 #cf_span[x] 的盒子添加到栈顶。保证恰好有 #cf_span[n] 行包含 "_add_" 操作,所有添加的盒子互不相同,且有 #cf_span[n] 行包含 "_remove_" 操作。同时保证每个盒子总是在被要求移除之前被添加。
## Output
请输出 Daru 成功完成所有 Okabe 指令所需的最少重新排序次数。
[samples]
## Note
在第一个样例中,Daru 应该在将盒子 #cf_span[3] 添加到栈后重新排序。在第二个样例中,Daru 应该在将盒子 #cf_span[4] 和盒子 #cf_span[7] 添加到栈后分别重新排序。
**Definitions**
Let $ n \in \mathbb{Z}^+ $ be the number of boxes.
Let $ C = (c_1, c_2, \dots, c_{2n}) $ be a sequence of $ 2n $ commands, where each $ c_i \in \{ \text{add}(x), \text{remove} \} $, with exactly $ n $ add and $ n $ remove commands.
Let $ A \subseteq \{1, 2, \dots, n\} $ be the set of box labels.
Let $ S_t $ be the stack (list) of boxes after $ t $ commands, with top at the end.
Let $ r_k $ be the $ k $-th remove command, requiring box $ b_k $ to be removed, where $ b_1, b_2, \dots, b_n $ is the permutation $ (1, 2, \dots, n) $.
**Constraints**
1. Each box $ x \in \{1, \dots, n\} $ is added exactly once before its corresponding remove command.
2. A remove command is valid only if the top of the stack is the required box; otherwise, a reordering is needed.
3. Daru may reorder the stack arbitrarily (i.e., permute its contents) at any time between commands, at a cost of 1 per reordering.
4. Reordering does not change the multiset of boxes in the stack, only their order.
**Objective**
Find the minimum number of reorderings required so that, for each remove command $ r_k $, the top of the stack is exactly $ b_k = k $.