Example

Input

3
y 7
y 6
n 5


Output

1
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

const int INF = 1e9;

int main(){
  int N;
  cin >> N;
  vector<char> D(N);
  vector<int> L(N);
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    cin >> D[i] >> L[i];
    if(D[i] == 'y') V.emplace_back(L[i],i);
  }
  sort(V.begin(), V.end());
  int ans = 0;
  for(auto p : V){
    if(L[p.second] >= INF) continue;
    ++ans;
    int idx = p.second, h = L[idx];
    for(int i = idx-1; i >= 0; --i){
      if(L[i] >= h and D[i] == 'n') break;
      if(L[i] >= h) L[i] = INF;
    }
    for(int i = idx+1; i < N; ++i){
      if(L[i] >= h and D[i] == 'n') break;
      if(L[i] >= h) L[i] = INF;
    }
  }
  cout << ans << endl;
}

