#include<bits/stdc++.h>
#define L (root%262150)*2+root/262150*262150
#define R (root%262150)*2+1+root/262150*262150
#define TL tree[root].l
#define TR tree[root].r
using namespace std;
int n,m,maxx=0,kkll;
struct node{
int l,r,sum,lazy=-1e9,lson,rson;
}tree[8888888];
void pushdown(int root){
tree[root].sum=tree[L].sum+tree[R].sum;
}
void build(int l,int r,int k,int root){
maxx=max(maxx,root+k);
tree[root+k].l=l;
tree[root+k].r=r;
if(l==r){
tree[root+k].sum=0;
return ;
}
int mid=(l+r)>>1;
build(l,mid,k,L);
build(mid+1,r,k,R);
pushdown(root+k);
}
void spread(int root){
if(tree[root].lazy!=-1e9){
int op=tree[root].lazy;
tree[L].lazy=op;
tree[R].lazy=op;
tree[L].sum=(tree[L].r-tree[L].l+1)*op;
tree[R].sum=(tree[R].r-tree[R].l+1)*op;
tree[root].lazy=-1e9;
}
}
void update(int root,int l,int r,int k){
if(l<=TL&&r>=TR){
tree[root].sum=k;
tree[root].lazy=k;
return ;
}
spread(root);
int mid=(TL+TR)>>1;
if(l<=mid) update(L,l,r,k);
if(r>mid) update(R,l,r,k);
pushdown(root);
}
int chack(int root,int l,int r){
int ans=0;
if(l<=TL&&r>=TR){
return tree[root].sum;
}
spread(root);
int mid=(TR+TL)>>1;
if(l<=mid) ans+=chack(L,l,r);
if(r>mid) ans+=chack(R,l,r);
pushdown(root);
return ans;
}
signed main(){
cin>>n>>kkll>>m;
for(int i=1;i<=30;i++){
build(1,100000,(i-1)*262150,1);
}
build(1,100000,30*262150,1);
update(30*262150+1,1,100000,1);
while(m--){
char op;
int x,y,k;
cin>>op;
if(op=='C'){
cin>>x>>y>>k;
for(int i=1;i<=31;i++){
update((i-1)*262150+1,x,y,0);
}
update((k-1)*262150+1,x,y,1);
}
else{
cin>>x>>y;
int ans=0;
for(int i=1;i<=31;i++){
if(chack((i-1)*262150+1,x,y)>0){
ans++;
}
}
cout<<ans<<'\n';
}
}
return 0;
}