#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<iomanip>
#include<math.h>
using namespace std;
char g;
long long n,m,i,l,r,x,t[1000000],t1[1000000];
void down(long long v,long long k){
if(t1[v]!=-1){
t[v*2]=t1[v]*(k-(k/2));t[v*2+1]=t1[v]*(k/2);
t1[v*2]=t1[v];t1[v*2+1]=t1[v];
t1[v]=-1;
}
}
void modi(long long v,long long l,long long r,long long lt,long long rt,long long x){
if((lt<=l)&&(rt>=r)&&(t1[v]!=-1)){
t1[v]=x;
t[v]=(r-l+1)*x;
return;
}
down(v,r-l+1);
long long mid=(l+r)/2;
if(lt<=mid)modi(v*2,l,mid,lt,rt,x);
if(rt>mid)modi(v*2+1,mid+1,r,lt,rt,x);
if(t1[v*2]==t1[v*2+1])t1[v]=t1[v*2];else t1[v]=-1;
t[v]=t[v*2]+t[v*2+1];
}
long long sum(long long v,long long l,long long r,long long lt,long long rt){
if((lt<=l)&&(rt>=r))return t[v];
down(v,r-l+1);
long long mid=(l+r)/2;
long long s=0;
if(lt<=mid)s+=sum(v*2,l,mid,lt,rt);
if(rt>mid)s+=sum(v*2+1,mid+1,r,lt,rt);
return s;
}
int main(){
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
cin>>n>>m;
for(i=0;i<m;i++){
cin>>g>>l>>r;
if(g=='A'){
cin>>x;
modi(1,1,n,l,r,x);
}else{
cout<<sum(1,1,n,l,r)<<"\n";
}
}
// system("PAUSE");
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxzdGRpby5oPgojaW5jbHVkZTxzdGRsaWIuaD4KI2luY2x1ZGU8aW9tYW5pcD4KI2luY2x1ZGU8bWF0aC5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2hhciBnOwpsb25nIGxvbmcgbixtLGksbCxyLHgsdFsxMDAwMDAwXSx0MVsxMDAwMDAwXTs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