rt
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <map>
#define N 1000001
using namespace std;
int n,m;
vector<int> v[N];
int c[N];
int lowbit(int x) { return x&-x; }
void upd(int x,int k) { for (int i=x;i<=n;i+=lowbit(i)) c[i]+=k; }
int ask(int x) { int res=0; for (int i=x;i;i-=lowbit(i)) res+=c[i]; return res; }
struct Tree { vector<pair<int,int> > id; }t[N<<2];
void upd1(int x,int l,int r,int L,int R,pair<int,int> id) {
// if (L>R) exit(0);
if (L<=l and r<=R) return t[x].id.push_back(id),void();
int mid=(l+r>>1);
if (L<=mid) upd1(x<<1,l,mid,L,R,id);
if (R>mid) upd1(x<<1|1,mid+1,r,L,R,id);
}
void upd2(int x,int l,int r,int pos) {
for (pair<int,int> i:t[x].id) {
if (v[i.first][i.second]) continue;
v[i.first][i.second]=1; int tmp=ask(i.first)-ask(i.first-1); int lst=tmp;
while (tmp+1<v[i.first].size() and v[i.first][tmp+1]) ++tmp;
if (tmp-lst) upd(i.first,tmp-lst);
// if (tmp-lst<0) exit(0);
}
t[x].id.clear();
if (l==r) return;
int mid=(l+r>>1);
if (pos<=mid) upd2(x<<1,l,mid,pos);
else upd2(x<<1|1,mid+1,r,pos);
}
inline int R() {
int x = 0; char c = getchar(); while (!isdigit(c)) c = getchar();
while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); return x;
}
int main() {
n=R(),m=R();
for (int i=1;i<=n;i++) {
v[i].push_back(0);
for (int l=1,r=i;l<=n;l+=i,r+=i) v[i].push_back(0),upd1(1,1,n,l,min(r,n),{i,l/i+1});
}
for (int i=1,op,h,l,r;i<=m;i++) {
op=R();
if (op==1) {
h=R();
upd2(1,1,n,h);
} else {
l=R(),r=R();
printf("%d\n",ask(r)-ask(l-1)+(r-l+1));
}
}
return 0;
}