Example

Input

3
y 7
y 6
n 5


Output

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

int main(void){
    int N; cin >> N;
    vector<int> f(N); vector<int> d(N);
    for(int i = 0; i < N; i++){
        char c; int l;
        cin >> c >> l;
        d[i] = (c == 'y'? true : false);
        f[i] = l;
    }

    vector<int> order(f);
    vector<int> o(N, -1);
    for(int i = 0; i < N; i++){
        int minv = 1001, mini = -1;
        for(int j = 0; j < N; j++){
            if(minv > order[j]){
                minv = order[j];
                mini = j;
            }
        }
        o[i] = mini;
        order[mini] = 1001;
    }

    int ans = 0;
    vector<int> used(N, false);
    for(int i = 0; i < N; i++){
        int idx = o[i];
        if(used[idx] == true || d[idx] == false) continue;
        used[idx] = true;
        ans++;
        for(int i = idx-1; i >= 0; i--){
            if(d[i] == false && f[i] >= f[idx]) break;
            used[i] = true;
        }
        for(int i = idx+1; i < N; i++){
            if(d[i] == false && f[i] >= f[idx]) break;
            used[i] = true;
        }
    }

    cout << ans << endl;

    return 0;
}