Example

Input

3
y 7
y 6
n 5


Output

1
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int N, l[1000];
  set<int> s;
  bool remove[1000];
  int size = 0;

  scanf("%d", &N);

  pair<int,int> p[1000];

  for (int i=0; i<N; i++) {
    char d[2];
    scanf("%s%d", d, l + i);
    remove[i] = d[0] == 'y';
    s.insert(i);
    p[i] = {l[i] * 2 + !remove[i], i};
    size += !remove[i];
  }

  sort(p, p+N);

  int ans = 0;

  for(int i=0; i<N; i++) {
    int idx = p[i].second;

    auto it = s.find(idx);

    if (it == s.end()) continue;
    if (!remove[*it]) { s.erase(it); continue; }

    ans++;

    while(it != s.end() && remove[*it]) {
      it = s.erase(it);
    }

    while(1) {
      if (s.begin() == it) break;
      it--;
      if (!remove[*it]) break;
      it = s.erase(it);
    }
  }

  cout << ans << endl;

  return 0;
}

