Example

Input

3
y 7
y 6
n 5


Output

1
#include<bits/stdc++.h>
using namespace std;
typedef pair<char,int> P;
typedef pair<int,int> P1;

int main(){
  
  int n, l;
  char d;
  
  cin>>n;

  vector<P> x;
  
  priority_queue<P1,vector<P1>,greater<P1> > q;
  
  for(int i=0;i<n;i++){
    
    cin>>d>>l;
    
    if(!i){
      x.push_back(P(d,l));
      continue;
    }
    
    if(d==x[x.size()-1].first){
      
      if(x[x.size()-1].first=='y')
	x[x.size()-1].second=min(x[x.size()-1].second,l);
      
      if(x[x.size()-1].first=='n')
	x[x.size()-1].second=max(x[x.size()-1].second,l);
      
    }else x.push_back(P(d,l));
    
  }
  
  for(int i=0;i<x.size();i++)
    if(x[i].first=='y') q.push(P1(x[i].second,i));

  vector<int> used(x.size(),0);
  
  int ans=0;
  
  while(!q.empty()){
    
    P1 t=q.top(); q.pop();
    
    int cost=t.first, node=t.second;
    
    if(used[node])continue;
    used[node]=1;
    
    ans++;
    
    for(int i=node-1;i>=0;i--){
      if(x[i].first=='n'&&cost<=x[i].second)break;
      used[i]=1;
    }
    
    for(int i=node+1;i<x.size();i++){
      if(x[i].first=='n'&&cost<=x[i].second)break;
      used[i]=1;
    }
    
  }

  cout<<ans<<endl;
  
  return 0;
}