#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=3e5;
int n,x,t[4*N],ob[4*N];
string s;
inline void push(int v,int l,int r){
if(ob[v]!=-1){
ob[v+v]=ob[v+v+1]=ob[v];
int mid=(r+l)>>1;
t[v+v]=(mid-l+1)*ob[v];
t[v+v+1]=(r-mid)*ob[v];
ob[v]=-1;
}
}
void update(int v,int l,int r,int tl,int tr,int val){
if(l>r || l>tr || tl>r || tl>tr){
return;
}
if(tl<=l && r<=tr){
t[v]=(r-l+1)*val;
ob[v]=val;
return;
}
push(v,l,r);
int mid=(r+l)>>1;
update(v+v,l,mid,tl,tr,val);
update(v+v+1,mid+1,r,tl,tr,val);
t[v]=t[v+v]+t[v+v+1];
}
int first_zero(int v,int l,int r,int tl,int tr){
/// if our interval full (so there's no zeros)
if(t[v]==r-l+1){
return -1;
}
if(l>r || l>tr || tl>r || tl>tr){
return -1;
}
if(l==r){
return l;
}
push(v,l,r);
int mid=(r+l)>>1;
/// we should find first position
int val=first_zero(v+v,l,mid,tl,tr);
if(val==-1){
return first_zero(v+v+1,mid+1,r,tl,tr);
}
else{
return val;
}
}
int first_one(int v,int l,int r,int tl,int tr){
/// if our interval empty (so there's no ones)
if(t[v]==0){
return -1;
}
if(l>r || l>tr || tl>r || tl>tr){
return -1;
}
if(l==r){
return l;
}
push(v,l,r);
int mid=(r+l)>>1;
/// we should find first position
int val=first_one(v+v,l,mid,tl,tr);
if(val==-1){
return first_one(v+v+1,mid+1,r,tl,tr);
}
else{
return val;
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
memset(ob,-1,sizeof(ob));
cin>>n;
for(int i=1;i<=n;i++){
cin>>s>>x;
if(s=="add"){
/// find first zero on interval x..M
int U=first_zero(1,0,M,x,M);
/// assing 0 on interval x..U-1
update(1,0,M,x,U-1,0);
/// assing 1 in position U
update(1,0,M,U,U,1);
}
else{
/// find first one on interval x..M
int U=first_one(1,0,M,x,M);
/// assing 1 on interval x..U-1
update(1,0,M,x,U-1,1);
/// assing 0 in position U
update(1,0,M,U,U,0);
}
/// sum on interval 0..M
cout<<t[1]<<"\n";
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgpjb25zdCBpbnQgTj0xZTUrNTsKY29uc3QgaW50IE09M2U1OwoKCgoKaW50IG4seCx0WzQqTl0sb2JbNCpOXTsKc3RyaW5nIHM7CgppbmxpbmUgdm9pZCBwdXNoKGludCB2LGludCBsLGludCByKXsKICAgIGlmKG9iW3ZdIT0tMSl7CiAgICAgICAgb2Jbdit2XT1vYlt2K3YrMV09b2Jbdl07CiAgICAgICAgaW50IG1pZD0ocitsKT4+MTsKICAgICAgICB0W3Yrdl09KG1pZC1sKzEpKm9iW3ZdOwogICAgICAgIHRbdit2KzFdPShyLW1pZCkqb2Jbdl07CiAgICAgICAgb2Jbdl09LTE7CiAgICB9Cn0KCnZvaWQgdXBkYXRlKGludCB2LGludCBsLGludCByLGludCB0bCxpbnQgdHIsaW50IHZhbCl7CiAgICBpZihsPnIgfHwgbD50ciB8fCB0bD5yIHx8IHRsPnRyKXsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBpZih0bDw9bCAmJiByPD10cil7CiAgICAgICAgdFt2XT0oci1sKzEpKnZhbDsKICAgICAgICBvYlt2XT12YWw7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgcHVzaCh2LGwscik7CiAgICBpbnQgbWlkPShyK2wpPj4xOwogICAgdXBkYXRlKHYrdixsLG1pZCx0bCx0cix2YWwpOwogICAgdXBkYXRlKHYrdisxLG1pZCsxLHIsdGwsdHIsdmFsKTsKICAgIHRbdl09dFt2K3ZdK3Rbdit2KzFdOwp9CgppbnQgZmlyc3RfemVybyhpbnQgdixpbnQgbCxpbnQgcixpbnQgdGwsaW50IHRyKXsKICAgIC8vLyBpZiBvdXIgaW50ZXJ2YWwgZnVsbCAoc28gdGhlcmUncyBubyB6ZXJvcykKICAgIGlmKHRbdl09PXItbCsxKXsKICAgICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBpZihsPnIgfHwgbD50ciB8fCB0bD5yIHx8IHRsPnRyKXsKICAgICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBpZihsPT1yKXsKICAgICAgICByZXR1cm4gbDsKICAgIH0KICAgIHB1c2godixsLHIpOwogICAgaW50IG1pZD0ocitsKT4+MTsKICAgIC8vLyB3ZSBzaG91bGQgZmluZCBmaXJzdCBwb3NpdGlvbgogICAgaW50IHZhbD1maXJzdF96ZXJvKHYrdixsLG1pZCx0bCx0cik7CiAgICBpZih2YWw9PS0xKXsKICAgICAgICByZXR1cm4gZmlyc3RfemVybyh2K3YrMSxtaWQrMSxyLHRsLHRyKTsKICAgIH0KICAgIGVsc2V7CiAgICAgICAgcmV0dXJuIHZhbDsKICAgIH0KfQoKaW50IGZpcnN0X29uZShpbnQgdixpbnQgbCxpbnQgcixpbnQgdGwsaW50IHRyKXsKICAgIC8vLyBpZiBvdXIgaW50ZXJ2YWwgZW1wdHkgKHNvIHRoZXJlJ3Mgbm8gb25lcykKICAgIGlmKHRbdl09PTApewogICAgICAgIHJldHVybiAtMTsKICAgIH0KICAgIGlmKGw+ciB8fCBsPnRyIHx8IHRsPnIgfHwgdGw+dHIpewogICAgICAgIHJldHVybiAtMTsKICAgIH0KICAgIGlmKGw9PXIpewogICAgICAgIHJldHVybiBsOwogICAgfQogICAgcHVzaCh2LGwscik7CiAgICBpbnQgbWlkPShyK2wpPj4xOwogICAgLy8vIHdlIHNob3VsZCBmaW5kIGZpcnN0IHBvc2l0aW9uCiAgICBpbnQgdmFsPWZpcnN0X29uZSh2K3YsbCxtaWQsdGwsdHIpOwogICAgaWYodmFsPT0tMSl7CiAgICAgICAgcmV0dXJuIGZpcnN0X29uZSh2K3YrMSxtaWQrMSxyLHRsLHRyKTsKICAgIH0KICAgIGVsc2V7CiAgICAgICAgcmV0dXJuIHZhbDsKICAgIH0KfQoKaW50IG1haW4oKXsKICAg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