#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> order_set;

order_set X;

int get(int y)
{
    int l=0,r=1e9+1;
    while(l<r)
    {
        int m=l+((r-l)>>1);
        if(m-X.order_of_key(m+1)<y)
            l=m+1;
        else
            r=m;
    }
    return l;
}

main()
 {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        char a;
        int b;
        cin>>a>>b;
        if(a=='L')
            cout<<get(b)<<endl;
        else
            X.insert(get(b));
    }
 }