#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 1000001;
int pos[MAXN], a[MAXN], b[MAXN], add[MAXN];
int n, m ,block;
void reset(int x)
{
int i;
int l = (x-1) * block + 1;
int r = x * block;
if (r > n) r = n;
for (i = l; i <= r; i++)
{
b[i] = a[i];
}
sort(b + l, b + r + 1);
}
int find(int x, int tar)
{
int l = (x - 1)*block + 1;
int r = x*block;
if (r > n) r = n;
int mid, ret=r;
while (l <= r)
{
mid = (l + r) >> 1;
if (b[mid] >= tar) r = mid-1;
else l = mid + 1;
}
return ret - l + 1;
}
void Modify(int L, int R, int tar)
{
int i;
if (pos[L] == pos[R]) //L ans R are in the same block
{
for (i = L; i <= R; i++)
{
a[i] += tar;
}
}
else
{
for (i = L; i <= pos[L] * block; i++)
a[i] += tar;
for (i = (pos[R ]-1) * block +1; i <= R; i++)
a[i] += tar;
}
reset(pos[L]);
reset(pos[R]);
for (i = pos[L] + 1; i < pos[R]; i++)
add[i] += tar;
}
int Query(int L, int R, int tar)
{
int d = 0, i;
if (pos[L] == pos[R])
{
for (i = L; i <= R; i++)
{
if (add[i] + a[i] >= tar)
d++;
}
}
else
{
for (i = L; i <= pos[L] * block; i++)
if (a[i] + add[pos[i]] >= tar)
d++;
for (i = (pos[R]-1) * block + 1; i <= R; i++)
if (a[i] + add[pos[i]] >= tar)
d++;
}
for (i = pos[L] + 1; i < pos[R]; i++)
d += find(i, tar-add[i]);
return d;
}
int main(int argc, char *argv[])
{
int i, j, x, y, z, T;
char op;
scanf("%d%d", &n, &T);
block = (int)sqrt(n);
for (i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
b[i] = i;
pos[i] = (i - 1) / block + 1;
}
if (n%block)
m = n / block + 1;
else m = n / block;
for (i = 1; i <= m; i++)
reset(i);
while (T--)
{
scanf("\n%c%d%d%d", &op, &x, &y, &z);
if (op == ‘M‘) Modify(x, y, z);
else printf("%d\n", Query(x, y, z));
}
return 0;
}