#include<bits/stdc++.h>
using namespace std;
int n,m,t[10000001],c,l,r;
int lowbit(int x){return x&-x;}
void Change(int x,int k){while(x<=n)t[x]+=k,x+=lowbit(x);}
int Query(int x){int s=0;while(x>0)s+=t[x],x-=lowbit(x);return s;}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>m;
while(m--){
cin>>c>>l;
if(c==1)cout<<Query(l)<<endl;
else cin>>r,Change(l,1);Change(r+1,-1);
}
return 0;
}
RT