#include <bits/stdc++.h>
using namespace std;
struct Tree {
  int l, r, x;
};
vector<Tree> h[7010];
set<int> ans;
int n, m, op, deep, l, r, x;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%d%d", &deep, &l, &r, &x);
      h[deep].push_back((Tree){l, r, x});
    } else {
      scanf("%d%d", &deep, &l);
      r = l;
      ans.clear();
      while (deep <= n) {
        for (int j = 0; j < h[deep].size(); j++)
          if ((h[deep][j].l <= l && l <= h[deep][j].r) ||
              (l <= h[deep][j].l && h[deep][j].l <= r))
            ans.insert(h[deep][j].x);
        int len = l - 1, pow = 1;
        while (pow <= l - 1) {
          len++;
          pow *= 2;
        }
        l = len + 1;
        len = r, pow = 1;
        while (pow <= r) {
          len++;
          pow *= 2;
        }
        r = len;
        deep++;
      }
      printf("%d\n", ans.size());
    }
  }
  return 0;
}
