#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
float a[100001], x;
int main() {
  int n, m, l, r, cnt, t;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%f", &a[i]);
  while (m--) {
    scanf("%d%d%d%f", &t, &l, &r, &x);
    if (t == 1)
      for (int i = l; i <= r; i++) a[i] -= a[i] > x ? x : 0;
    else {
      cnt = 0;
      for (int i = l; i <= r; i++) a[i] == x ? cnt++ : 0;
      printf("%d\n", cnt);
    }
  }
}
