#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int n, m;
int two[110000], sum[110000];
vector<int> d, l, r, x;
int L[7005], R[7005];
int M[1000005];
vector<int> S;
void solve() {
  l.reserve(7005);
  r.reserve(7005);
  x.reserve(7005);
  S.reserve(7005);
  for (int i = 0; i < m; i++) {
    int t, td;
    cin >> t >> td;
    if (t == 1) {
      int tl, tr, tx;
      cin >> tl >> tr >> tx;
      d.push_back(td);
      l.push_back(tl);
      r.push_back(tr);
      x.push_back(tx);
    } else {
      for (int j = 1; j < td; j++) {
        L[j] = R[j] = -1;
      }
      int v;
      cin >> v;
      L[td] = v - 1;
      R[td] = v;
      while (td < n) {
        L[td + 1] = L[td] + sum[L[td]];
        R[td + 1] = R[td] + sum[R[td]];
        td++;
      }
      int ans = 0;
      S.clear();
      for (size_t j = 0; j < d.size(); j++) {
        int depth = d[j];
        if (L[depth] != -1 && max(L[depth] + 1, l[j]) <= min(R[depth], r[j]) &&
            M[x[j]] == false) {
          M[x[j]] = true;
          S.push_back(x[j]);
          ans++;
        }
      }
      for (size_t j = 0; j < S.size(); j++) {
        M[S[j]] = false;
      }
      cout << S.size() << endl;
    }
  }
}
int main() {
  int p = 1;
  while (p < 110000) {
    two[p]++;
    p *= 2;
  }
  for (int i = 1; i < 110000; i++) {
    sum[i] = two[i] + sum[i - 1];
  }
  ios_base::sync_with_stdio(false);
  while (cin >> n >> m) {
    solve();
  }
}
