Example

Input

3
y 7
y 6
n 5


Output

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

int main() {
    int N;
    cin >> N;
    vector<char> D(N);
    vector<int> L(N);
    vector<bool> del(N);
    for(int i=0; i<N; ++i) {
        cin >> D[i] >> L[i];
    }
    int res = 0;
    while(true) {
        int idx = -1;
        for(int i=0; i<N; ++i) {
            if(D[i] == 'n' || del[i]) {
                continue;
            }
            if(idx == -1 || L[i] < L[idx]) {
                idx = i;
            }
        }
        if(idx == -1) {
            break;
        }
        res++;
        int l = idx-1, r = idx+1;
        while(0 < l && (del[l] || D[l] == 'y' || (D[l] == 'n' && L[l] < L[idx]))) {
            --l;
        }
        while(r < N-1 && (del[r] || D[r] == 'y' || (D[r] == 'n' && L[r] < L[idx]))) {
            ++r;
        }
        for(int i=l; i<=r; ++i) {
            if(D[i] == 'y') {
                del[i] = true;
            }
        }
    }
    cout << res << endl;
}
