Example

Input

3
y 7
y 6
n 5


Output

1
#include <bits/stdc++.h>

using namespace std;

typedef pair< int, int > Pi;

int main()
{
  int N;
  char D[1000];
  int L[1000];

  vector< Pi > beet;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> D[i] >> L[i];
    if(D[i] == 'y') beet.emplace_back(L[i], i);
  }
  sort(begin(beet), end(beet));
  int ret = 0;
  bool v[1000] = {};
  for(auto &p : beet) {
    if(v[p.second]++) continue;
    ++ret;
    for(int i = p.second - 1; i >= 0; i--) {
      if(D[i] == 'n' && p.first <= L[i]) break;
      v[i] = true;
    }
    for(int i = p.second + 1; i < N; i++) {
      if(D[i] == 'n' && p.first <= L[i]) break;
      v[i] = true;
    }
  }
  cout << ret << endl;
}