#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    ans = 0;
    int a1, l, r, x;
    cin >> a1 >> l >> r >> x;
    if (a1 == 1) {
      for (int i = 1; i <= r; i++) {
        a[i] -= (a[i] > x) ? x : 0;
      }
    } else {
      for (int i = 1; i <= r; i++) {
        ans += !(a[i] - x);
      }
      cout << ans << endl;
    }
  }
  return 0;
}
