#include <bits/stdc++.h>
using namespace std;
struct Interval {
  int level, from, to, x;
  Interval(int level_ = -1, int from_ = 0, int to_ = 0, int x_ = 0)
      : level(level_), from(from_), to(to_), x(x_) {}
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > children(100 * n);
  children[1] = vector<int>(2, 1);
  children[1][1] = 2;
  for (int i = 2; i < int(children.size()); ++i) {
    children[i] = vector<int>(1, children[i - 1].back() + 1);
    if ((i & -i) == i) {
      children[i].push_back(children[i][0] + 1);
    }
  }
  vector<vector<Interval> > intervals(n + 1);
  for (int q = 1; q <= m; ++q) {
    int t;
    cin >> t;
    if (t == 2) {
      int level, pos;
      cin >> level >> pos;
      set<int> res;
      int left = pos, right = pos;
      for (int i = level; i <= n; ++i) {
        for (size_t j = 0; j < intervals[i].size(); ++j) {
          if (left <= intervals[i][j].to && right >= intervals[i][j].from) {
            res.insert(intervals[i][j].x);
          }
        }
        left = children[left][0];
        right = children[right].back();
      }
      cout << res.size() << endl;
    } else {
      int level, from, to, x;
      cin >> level >> from >> to >> x;
      intervals[level].push_back(Interval(level, from, to, x));
    }
  }
  return 0;
}
