Example

Input

3
y 7
y 6
n 5


Output

1
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define  MP make_pair
#define  PB push_back
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>v(n);
    vector<bool>flag(n,1);
    vector<bool>y(n);
    vector<pair<int,int> > p;
    rep(i,n){
        char c;
        int a;
        cin >> c >> a;
        if(c=='y'){
            y[i] = 1;
        }
        v[i] = a;
        if(c=='y')p.PB(MP(v[i],i));
    }
    sort(p.begin(),p.end());
    int ans = 0;
    rep(i,p.size()){
        int ind = p[i].second;
        int l=ind,r=ind;
        int h = p[i].first;
        if(!flag[ind])continue;
        ans++;
        for(int k = ind+1;k<n;k++){
            if(!y[k]){
                if(h<=v[k]){
                    break;
                }
            }
            r = k;
        }
        for(int k = ind-1;k>=0;k--){
            if(!y[k]){
                if(h<=v[k]){
                    break;
                }
            }
            l = k;
        }
        for(int k=l;k<=r;k++){
            flag[k] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}
