Example

Input

3
y 7
y 6
n 5


Output

1
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> type(n+2);
    vector<int> height(n+2);
    
    type[0] = 1;
    height[0] = INF/2;
    type[1] = 0;
    height[1] = INF;
    
    rep(i,n){
        char ch;
        int h;
        cin>>ch>>h;
        type[i+2] = (ch=='y'?1:0);
        height[i+2] = h;
    }
    
    vector<int> v;
    
    int ntype = -1;
    int nh = -1;
    rep(i,type.size()){
        if(ntype==-1){
            ntype = type[i];
            nh = height[i];
        }else if(type[i]==ntype){ //same type
            if(ntype==1)    nh = min(nh,height[i]);
            else            nh = max(nh,height[i]);
        }else{  //different type
            v.pb(nh);
            
            ntype = type[i];
            nh = height[i];
        }
    }
    v.pb(nh);
    
    int ans = 0;
    vector<bool> used(v.size(),0);
    int less = (v.size()+1)/2;
    while(less){
        int mini = INF;
        int pos = -1;
        for(int i=0;i<v.size();i+=2){
            if(mini>v[i] && used[i]==false){
                mini = v[i];
                pos = i;
            }
        }
        assert(pos!=-1);
        
        ans++;
        used[pos] = true;
        less--;
        
        int l = pos, r=pos;
        while(l-2>=0 && v[l-1]<v[pos]){
            l-=2;
            if(v[l]>=v[pos] && !used[l]){
                less--;
                used[l] = true;
            }
        }
        while(r+2<v.size() && v[r+1]<v[pos]){
            r+=2;
            if(v[r]>=v[pos] && !used[r]){
                less--;
                used[r] = true;
            }
        }
        //        cout<<pos<<" "<<l<<" "<<r<<endl;
        
    }
    cout<<ans-1<<endl;
    
}

