Example

Input

3
y 7
y 6
n 5


Output

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

char D[1000];
int L[1000];
int N, ans;
int check[1000];
typedef pair<int, int> P;

int main() {
	cin >> N;

	vector<P> ord;
	for(int i = 0; i < N; i++) {
		cin >> D[i] >> L[i];
		if(D[i] == 'y') ord.push_back({ L[i], i });
	}
	sort(ord.begin(), ord.end());

	int ans = 0;
	for(auto p : ord) {
		int l = p.first, id = p.second;
		if(check[id]) continue;
		ans++;
		for(int i = id + 1; i < N; i++) {
			if(check[i]) continue;
			if(D[i] == 'y') {
				check[i] = 1;
			}
			else {
				if(l <= L[i]) break;
			}
		}
		for(int i = id - 1; i >= 0; i--) {
			if(check[i]) continue;
			if(D[i] == 'y') {
				check[i] = 1;
			}
			else {
				if(l <= L[i]) break;
			}
		}
	}
	cout << ans << endl;
}