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