#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, a[100001];
static char buf[1000000], *p1 = buf, *p2 = buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
int main()
{
n = read(); m = read();
for(int i = 1; i <= n; i++) a[i] = read();
for(int j = 1; j <= m; j++)
{
int opt, l, r, ans = 0;
double x;
opt = read(); l = read(); r = read(); x = read();
if(opt == 1)
{
for(int i = l; i <= r; i++)
if(a[i] > x) a[i] -= x;
}
else
{
for(int i = l; i <= r; i++)
if(a[i] == x) ans++;
printf("%d\n",ans);
}
}
return 0;
}