#include <bits/stdc++.h>
using namespace std;
const int SIZE = 8000;
int ut[SIZE];
int ul[SIZE];
int ur[SIZE];
int ux[SIZE];
int now;
int bl[SIZE];
int br[SIZE];
int N, M;
int radix[32];
int main() {
  radix[0] = 1;
  for (int i = 1; i < 32; i++) radix[i] = radix[i - 1] * 2;
  scanf("%d%d", &N, &M);
  while (M--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int tt, ll, rr, xx;
      scanf("%d%d%d%d", &tt, &ll, &rr, &xx);
      ut[now] = tt;
      ul[now] = ll;
      ur[now] = rr;
      ux[now] = xx;
      now++;
    } else {
      set<int> ans;
      int tt, vv;
      scanf("%d%d", &tt, &vv);
      bl[tt] = br[tt] = vv;
      int ri = 0;
      for (int i = tt + 1; i <= 7000; i++) {
        while (radix[ri] <= bl[i - 1] - 1) ri++;
        bl[i] = bl[i - 1] - 1 + ri + 1;
      }
      ri = 0;
      for (int i = tt + 1; i <= 7000; i++) {
        while (radix[ri] <= br[i - 1]) ri++;
        br[i] = br[i - 1] + ri;
      }
      for (int i = 0; i < now; i++)
        if (ut[i] >= tt && ul[i] <= br[ut[i]] && bl[ut[i]] <= ur[i])
          ans.insert(ux[i]);
      printf("%d\n", (int)ans.size());
    }
  }
  return 0;
}
