Example

Input

3
y 7
y 6
n 5


Output

1
#include<bits/stdc++.h>
using namespace std;

int n;
char a[1000];
int b[1000];
bool flg[1000];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  int ans=0;
  while(1){
    int id=-1;
    for(int i=0;i<n;i++){
      if(flg[i]||a[i]=='n')continue;
      if(id==-1||b[i]<b[id])id=i;
    }
    if(id==-1)break;
    ans++;
    int l=id,r=id;
    while(0<=l-1&&(a[l-1]=='y'||b[l-1]<b[id]))l--;
    while(r+1<n&&(a[r+1]=='y'||b[r+1]<b[id]))r++;
    for(int i=l;i<=r;i++)flg[i]=true;
  }
  cout<<ans<<endl;
  return 0;
}