#include <bits/stdc++.h>
using namespace std;
vector<int> l[7100], r[7100], x[7100];
int s[7100], fl[10001000], fr[10001000];
bool is_pow2(int x) {
  while (x) {
    if (x == 1) break;
    if (x % 2 == 1) return false;
    x /= 2;
  }
  return true;
}
void init() {
  int lp = 1;
  for (int i = 1; i < 10001000; i++) {
    fl[i] = lp;
    if (is_pow2(i)) lp++;
    fr[i] = lp++;
  }
}
int main() {
  init();
  int n, m, id, t, li, ri, xi, v, tot;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &id);
    if (id == 1) {
      scanf("%d%d%d%d", &t, &li, &ri, &xi);
      l[t].push_back(li);
      r[t].push_back(ri);
      x[t].push_back(xi);
    } else {
      scanf("%d%d", &t, &v);
      li = ri = v, tot = 0;
      for (int i = t; i <= n; i++) {
        for (int j = 0; j < l[i].size(); j++) {
          int t1 = l[i][j], t2 = r[i][j];
          if (l[i][j] <= ri && li <= r[i][j]) s[tot++] = x[i][j];
        }
        li = fl[li];
        ri = fr[ri];
      }
      if (tot == 0)
        printf("0\n");
      else {
        int ms = 1;
        sort(s, s + tot);
        for (int i = 1; i < tot; i++) {
          if (s[i - 1] < s[i]) ms++;
        }
        printf("%d\n", ms);
      }
    }
  }
  return 0;
}
