#include typedef long long ll; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,a) FOR(i,0,a) using namespace std; const int MAX_N=1e5; int n,n2; struct query{ int typ; int a,b; query(int t=-1,int a=0,int b=0):typ(t),a(a),b(b){} }; query qry[MAX_N]; int seg[MAX_N<<3]; void segchange(int x,int y){ seg[n2-1+x]+=y; x=n2-1+x; while(x>0){ x=(x-1)/2; seg[x]=seg[x*2+1]+seg[x*2+2]; } } int segquery(int l,int r,int k,int a,int b){ if(r<=a || b<=l){ return 0; } if(l<=a && b<=r){ return seg[k]; } return segquery(l,r,k*2+1,a,(a+b)/2)+segquery(l,r,k*2+2,(a+b)/2,b); } int main(){ cin>>n; vector cmp; REP(i,n){ int t,a,b; cin>>t>>a>>b; qry[i]=query(t,a,b); cmp.push_back(a); if(t==1){ cmp.push_back(b+1); qry[i].b++; } } sort(cmp.begin(),cmp.end()); cmp.erase(unique(cmp.begin(),cmp.end()),cmp.end()); REP(i,n){ qry[i].a=lower_bound(cmp.begin(),cmp.end(),qry[i].a)-cmp.begin(); if(qry[i].typ==1){ qry[i].b=lower_bound(cmp.begin(),cmp.end(),qry[i].b)-cmp.begin(); } } n2=1; while(n2<(int)cmp.size())n2<<=1; ll ans=0; REP(i,n){ if(qry[i].typ==0){ segchange(qry[i].a,qry[i].b); }else{ ans+=segquery(qry[i].a,qry[i].b,0,0,n2); } } cout<