Example

Input

3
y 7
y 6
n 5


Output

1
#include <bits/stdc++.h>
using namespace std;
struct dat{int h,f;};

vector<dat> compless(vector<dat> A,int h){
  int n=A.size();
  for(int i=0;i<n-1;i++){
    if(A[i].f&&A[i+1].f)A[i+1].h=max(A[i+1].h,A[i].h),A[i]=(dat){0,0};
    if(A[i].f||A[i].h<=h)continue;
    int mn=A[i].h,idx=i;
    A[i]=(dat){0,0};
    while((A[++i].f&&h>=A[i].h)||!A[i].f){
      if(!A[i].f&&h>=A[i].h)continue;
      if(!A[i].f)mn=min(mn,A[i].h),idx=i;
      A[i]=(dat){0,0};
    }
    A[idx] = (dat){mn,0}; 
    i = idx;
  }
  vector<dat> res;
  for(int i=0;i<n;i++)if(A[i].h) res.push_back(A[i]);
  return res;
}
typedef pair<int,int>P;

int solve(vector<dat> A){
  vector<int> H;
  A=compless(A,0);
  for(int i=0;i<A.size();i++)if(A[i].f)H.push_back(A[i].h);
  sort(H.begin(),H.end());
  vector<dat> B[2]={A};
  for(int i=0;i<H.size();i++)B[(i+1)%2] = compless(B[i%2],H[i]);
  A = B[H.size()%2];
  int res=0;
  for(int i=0;i<A.size();i++)res+=!A[i].f;
  return res;
}

int main(){
  int n;
  cin>>n;
  vector<dat> A;
  A.resize(n+2);
  A[n]=(dat){10000,1};
  char ch;
  for(int i=0;i<n;i++)cin>>ch>>A[i].h,A[i].f = ch=='n';
  cout<<solve(A)<<endl;
  return 0;
}