#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
using namespace std;
const int N = 100005;
int a[N];
int main() {
  int n, m, op, l, r, ans;
  float x;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  while (m--) {
    scanf("%d%d%d%d", &op, &l, &r, &x);
    if (op == 1) {
      for (int i = l; i <= r; i++)
        if (a[i] > x) a[i] -= x;
    } else {
      ans = 0;
      for (int i = l; i <= r; i++)
        if (a[i] == x) ++ans;
      printf("%d\n", ans);
    }
  }
  return 0;
}
