#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long int, long long int>, long long int> > v[8000];
set<long long int> S;
long long int n, m;
long long int LOG(long long int x) {
  int r = 0;
  while (x) {
    r++;
    x >>= 1;
  }
  return r;
}
int main() {
  long long int t, lev, pos, l, r, x;
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  while (m--) {
    cin >> t;
    if (t == 1) {
      cin >> lev >> l >> r >> x;
      v[lev].push_back(make_pair(make_pair(l, r), x));
    } else {
      cin >> lev >> pos;
      l = r = pos;
      S.clear();
      while (lev <= n) {
        for (int i = 0; i <= (int)v[lev].size() - 1; i++)
          if (max(l, v[lev][i].first.first) <= min(r, v[lev][i].first.second))
            S.insert(v[lev][i].second);
        if (l != 1) l += LOG(l - 1);
        r += LOG(r);
        lev++;
      }
      cout << S.size() << endl;
    }
  }
}
