#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define cty cout<<"Yes"<<endl
#define ctn cout<<"No"<<endl
#define dbg(x) cout<<<<#x<<" : "<<x<<endl
#define int long long
const ll mod = 1e8;
const int mxn = 1e6+10;
int a[mxn];
int l[10000],r[10000],belong[mxn];
int cop[mxn],tag[10000];
int n,q;
int blocksize,tot;
void build(){
blocksize = (int)(sqrtl(n));
tot = (n+blocksize-1)/blocksize;
for(int i = 1;i <= n; i++){
belong[i] = (i-1)/blocksize+1;
}
for(int i = 1;i <= tot; i++){
l[i] = (i-1)*blocksize+1;
r[i] = min(i*blocksize,n);
sort(cop+l[i],cop+r[i]+1);
}
r[tot] = n;
}
void modifypart(int id,int ll,int rr,int w){
for(int i = ll;i <= rr; i++){
a[i]+=w;
}
memcpy(cop+l[id], a+l[id], r[id]-l[id]+1*sizeof(int));
sort(cop+l[id],cop+r[id]+1);
}
void modify(int ll,int rr,int w){
int bel = belong[ll],ber = belong[rr];
if(bel==ber){
modifypart(bel,ll,rr,w);
return;
}
modifypart(belong[ll], ll, r[belong[ll]], w);
modifypart(belong[rr], l[belong[rr]], rr, w);
for(int i = bel+1;i < ber; i++) tag[i]+=w;
}
int querypart(int id,int ll,int rr,int c){
int res = 0;
for(int i = ll;i <= rr; i++){
if(a[i]+tag[id]>=c) res++;
}
return res;
}
int query(int ll,int rr,int c){
if(belong[ll]==belong[rr]){
return querypart(belong[ll],ll,rr,c);
}
int ansl = querypart(belong[ll], ll, r[belong[ll]], c);
int ansr = querypart(belong[rr], l[belong[rr]], rr, c);
int ansz = 0;
for(int i = belong[ll]+1;i < belong[rr]; i++){
int temp = lower_bound(cop+l[i],cop+r[i]+1,c-tag[i])-cop;
ansz+=(r[i]-temp+1);
}
return ansl+ansr+ansz;
}
void LonelyLunar_solve(){
cin>>n>>q;
for(int i = 1;i <= n; i++){
cin>>a[i];
cop[i] = a[i];
}
build();
while(q--){
char v;
cin>>v;
if(v=='M'){
int l,r,w;
cin>>l>>r>>w;
modify(l, r, w);
}
else if(v=='A'){
int l,r,c;
cin>>l>>r>>c;
cout<<query(l, r, c)<<endl;
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _ = 1;
while(_--){
LonelyLunar_solve();
}
return 0;
}