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