#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
set<int> ans;
int n, m;
int two[1101000];
vector<pair<pair<int, int>, int> > arr[7011];
int was[1000100];
int func(int a) {
  if (was[a]) return was[a];
  int cnt = 0;
  for (int i = 0; i <= 20; ++i)
    if ((1 << i) < a) ++cnt;
  return was[a] = cnt;
}
void get_ans(int lvl, int l, int r) {
  if (lvl == n + 1) return;
  for (int i = 0; i < arr[lvl].size(); ++i) {
    if (arr[lvl][i].first.first > r || arr[lvl][i].first.second < l) continue;
    ans.insert(arr[lvl][i].second);
  }
  get_ans(lvl + 1, l + func(l), r + func(r + 1));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= 20; ++i) two[1 << i] = 1;
  for (int i = 0; i < m; ++i) {
    int t;
    scanf("%d", &t);
    int lvl, v, l, r, x;
    if (t == 2) {
      scanf("%d%d", &lvl, &v);
      ans.clear();
      get_ans(lvl, v, v);
      printf("%d\n", ans.size());
    } else {
      scanf("%d%d%d%d", &lvl, &l, &r, &x);
      arr[lvl].push_back(make_pair(make_pair(l, r), x));
    }
  }
  return 0;
}
