#include<bits/stdc++.h>
using namespace std;
const int MAXN=1000005;
const int SQN=10005;
int a[MAXN]={};
int st[SQN]={};
int ed[SQN]={};
int belong[MAXN]={};
int sz[SQN]={};
int n,q;
int lazy[SQN]={};
vector<int> ms[SQN]={};
void update(int index){
for(int i=0;i<sz[index];i++){
ms[index][i]=a[st[index]+i];
}
sort(ms[index].begin(),ms[index].end());
}
void init(int n){
int sq=sqrt(n);
for(int i=1;i<=sq;i++){
st[i]=n/sq*(i-1)+1;
ed[i]=n/sq*i;
}
ed[sq]=n;
for(int i=1;i<=sq;i++){
for(int j=st[i];j<=ed[i];j++){
belong[j]=i;
}
}
for(int i=1;i<=n;i++){
sz[i]=ed[i]-st[i]+1;
}
}
void modify(int l,int r,int w){
if(belong[l]==belong[r]){
for(int i=l;i<=r;i++){
a[i]+=w;
}
update(belong[l]);
return ;
}
for(int i=l;i<=ed[belong[l]];i++){
a[i]+=w;
}
for(int i=st[belong[r]];i<=r;i++){
a[i]+=w;
}
update(belong[l]);
update(belong[r]);
for(int i=belong[l]+1;i<belong[r];i++){
lazy[i]+=w;
}
}
void query(int l,int r,int c){
int tot=0;
if(belong[l]==belong[r]){
for(int i=l;i<=r;i++){
if(a[i]+lazy[belong[l]]>=c){
tot++;
}
}
cout<<tot<<endl;
return ;
}
for(int i=l;i<=ed[belong[l]];i++){
if(a[i]+lazy[belong[l]]>=c){
tot++;
}
}
for(int i=st[belong[r]];i<=r;i++){
if(a[i]+lazy[belong[r]]>=c){
tot++;
}
}
for(int i=belong[l]+1;i<belong[r];i++){
int temp= ms[i].end()-std::lower_bound(ms[i].begin(), ms[i].end(),c-lazy[i]);
tot+=temp;
}
cout<<tot<<endl;
};
int main(){
cin>>n>>q;
int sq=sqrt(n);
for(int i=1;i<=n;i++){
cin>>a[i];
}
init(n);
for (int i = 1; i <= sq; ++i) {
for (int j = st[i]; j <= ed[i]; ++j) {
ms[i].push_back(a[j]);
}
}
for (int i = 1; i <= sq; ++i)
sort(ms[i].begin(), ms[i].end());
for(int i=0;i<q;i++){
char opcode;
int l,r,w;
cin>>opcode>>l>>r>>w;
if(opcode=='M'){
modify(l,r,w);
}
else{
query(l,r,w);
}
}
}