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