#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000000 + 10;
const int NUM = 100000;
int n, m;
int l[MAX], r[MAX];
int sum[MAX], cnt[MAX];
pair<pair<int, int>, pair<int, int> > q[NUM];
int top, hashx[MAX];
int L[NUM], R[NUM];
int main() {
  int i, j, tot = 0;
  cin >> n >> m;
  for ((i) = (1); (i) != (MAX); ++(i)) {
    r[i] = l[i] = ++tot;
    if ((i & (i - 1)) == 0) r[i] = ++tot;
    sum[i] = tot;
  }
  cnt[1] = 1;
  for ((i) = (2); (i) <= (n); ++(i)) cnt[i] = sum[cnt[i - 1]];
  for ((i) = (1); (i) <= (m); ++(i)) {
    int t, v, type;
    cin >> type;
    if (type == 1) {
      int l, r;
      scanf("%d%d%d%d", &t, &l, &r, &v);
      q[++top] = make_pair(make_pair(t, v), make_pair(l, r));
    } else {
      int ans = 0;
      scanf("%d%d", &t, &v);
      L[t] = v, R[t] = v;
      for ((j) = (t + 1); (j) <= (n); ++(j)) {
        L[j] = l[L[j - 1]];
        R[j] = r[R[j - 1]];
      }
      for ((j) = (1); (j) <= (top); ++(j))
        if (q[j].first.first >= t) {
          int a = q[j].first.first;
          if (L[a] > q[j].second.second || R[a] < q[j].second.first) continue;
          if (hashx[q[j].first.second] != i) {
            hashx[q[j].first.second] = i;
            ++ans;
          }
        }
      printf("%d\n", ans);
    }
  }
  return 0;
}
