#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int st[maxn],tt=0;
int main(){
int n,k,op,curv,ans=0,cnt=0;
scanf("%d",&n);
while(n--){
scanf("%d",&op);
if(op==1){
scanf("%d",&curv);
}
else if(op==2){
ans+=cnt;
cnt=0;
}
else if(op==3){
scanf("%d",&st[++tt]);
}
else if(op==4) cnt=0;
else if(op==5) tt=0;
else cnt++;
while(tt&&st[tt]<curv){
ans++;
tt--;
}
}
printf("%d",ans);
}
894A - QAQ | 1551A - Polycarp and Coins |
313A - Ilya and Bank Account | 1469A - Regular Bracket Sequence |
919C - Seat Arrangements | 1634A - Reverse and Concatenate |
1619C - Wrong Addition | 1437A - Marketing Scheme |
1473B - String LCM | 1374A - Required Remainder |
1265E - Beautiful Mirrors | 1296A - Array with Odd Sum |
1385A - Three Pairwise Maximums | 911A - Nearest Minimums |
102B - Sum of Digits | 707A - Brain's Photos |
1331B - Limericks | 305B - Continued Fractions |
1165B - Polycarp Training | 1646C - Factorials and Powers of Two |
596A - Wilbur and Swimming Pool | 1462B - Last Year's Substring |
1608B - Build the Permutation | 1505A - Is it rated - 2 |
169A - Chores | 765A - Neverending competitions |
1303A - Erasing Zeroes | 1005B - Delete from the Left |
94A - Restoring Password | 1529B - Sifid and Strange Subsequences |