specific double-ended cohort
topic description
There is a specific double-ended queue, which can add data from the head to the tail, but can only remove data from the head.
Little A executes 2n instructions at a time to add data and remove data to the queue,
among which n instructions are to add data (maybe from the head or from the tail)
to add 1 to n in turn, and n instructions are to move out data.
Now it is required to move The order of removing data is from 1 to n.
In order to meet the requirements of the final output,
Little A can adjust the order of data in the queue at any time.
Excuse me, Little A needs to adjust at least several times to meet the order of removing data, which is exactly 1 to n
enter description
The first line is an integer n, indicating the range of data.
Next there are 2n lines, of which n lines add data:
the command head add x means add data x from the head,
tail add x means add data x from the tail,
and n lines remove data instructions , the instruction is in the form of remove, which means to remove a piece of data
1 ≤ n ≤ 3×10 5
output description
An integer, indicating the minimum number of adjustments for Little A
example one
enter
3
head add 1
remove
tail add