Example

Input

3
y 7
y 6
n 5


Output

1
#include <bits/stdc++.h>
int main()
{
    int N;
    std::cin >> N;
    std::vector<char> D(N);
    std::vector<int> L(N);
    std::vector<bool> done(N, false);
    constexpr int MAX = 1000;
    for (int i = 0; i < N; i++) { std::cin >> D[i] >> L[i]; }
    std::vector<int> S;
    for (int i = 0; i <= MAX; i++) {
        for (int j = 0; j < N; j++) {
            if (L[j] == i and D[j] == 'y') { S.push_back(j); }
        }
    }
    int ans = 0;
    for (const int s : S) {
        if (done[s]) { continue; }
        ans++;
        for (int i = s; i < N; i++) {
            if (L[i] >= L[s] and D[i] == 'n') { break; }
            done[i] = true;
        }
        for (int i = s; i >= 0; i--) {
            if (L[i] >= L[s] and D[i] == 'n') { break; }
            done[i] = true;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

