Example

Input

3
y 7
y 6
n 5


Output

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

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

  priority_queue<P,vector<P>,greater<P> > q;
  
  for(int i=0;i<n;i++){
    
    cin>>d[i]>>l[i];
    
    if(d[i]=='y') q.push(P(l[i],i));
    
  }
  
  vector<bool> used(n,0);
  
  int ans=0;
  
  while(!q.empty()){
    
    P 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(d[i]=='n'&&cost<=l[i])break;
      used[i]=1;
    }
    
    for(int i=node+1;i<n;i++){
      if(d[i]=='n'&&cost<=l[i])break;
      used[i]=1;
    }
    
  }

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