#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));
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4KI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsKCnR5cGVkZWYgdHJlZTxpbnQsbnVsbF90eXBlLGxlc3M8aW50PixyYl90cmVlX3RhZyx0cmVlX29yZGVyX3N0YXRpc3RpY3Nfbm9kZV91cGRhdGU+IG9yZGVyX3NldDsKCm9yZGVyX3NldCBYOwoKaW50IGdldChpbnQgeSkKewogICAgaW50IGw9MCxyPTFlOSsxOwogICAgd2hpbGUobDxyKQogICAgewogICAgICAgIGludCBtPWwrKChyLWwpPj4xKTsKICAgICAgICBpZihtLVgub3JkZXJfb2Zfa2V5KG0rMSk8eSkKICAgICAgICAgICAgbD1tKzE7CiAgICAgICAgZWxzZQogICAgICAgICAgICByPW07CiAgICB9CiAgICByZXR1cm4gbDsKfQoKbWFpbigpCiB7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgbixtOwogICAgY2luPj5uPj5tOwoKICAgIGZvcihpbnQgaT0wO2k8bTtpKyspCiAgICB7CiAgICAgICAgY2hhciBhOwogICAgICAgIGludCBiOwogICAgICAgIGNpbj4+YT4+YjsKICAgICAgICBpZihhPT0nTCcpCiAgICAgICAgICAgIGNvdXQ8PGdldChiKTw8ZW5kbDsKICAgICAgICBlbHNlCiAgICAgICAgICAgIFguaW5zZXJ0KGdldChiKSk7CiAgICB9CiB9