13531 - Cutting Wood   

Description

We have a long piece of wood whose length is \(L\).

There are \(Q\) queries each consisting of a character and an integer \((c_i, x_i)\):

  • \(c_i=\)'a', cut the wood at postion \(x_i\) from left end.
  • \(c_i=\)'b', print out the length of piece to which postion \(x_i\) belong.

It's guranteed that it wouldn't be cut at postion \(x_i\) when you're asked to print out the length.

Input

There are two integers \(L, Q\) in the first line respectively.

The following \(Q\) lines contain a character and an integer \(c_i, x_i\).

 

Output

For queries where \(c_i=\)'b', print out the length of piece to which postion \(x_i\) belong. Remember to put a new line character at the end of each such query.

Sample Input  Download

Sample Output  Download

Tags




Discuss