Example

Input

3
y 7
y 6
n 5


Output

1
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> len(n);
	vector<char> d(n);
	vector<pair<int, int> > shorter(n);
	for(int i=0; i<n; i++){
		cin >> d[i] >> len[i];
		shorter[i] = make_pair(len[i], i);
	}
	sort(shorter.begin(), shorter.end());

	int ans = 0;
	for(int i=0; i<n; i++){
		int curr = shorter[i].second;
		if(d[curr] != 'y') continue;
		for(int j=curr; j>=0; j--){
			if(d[j]=='n' && len[j] >= len[curr]) break;
			if(d[j]=='y' && len[j] >= len[curr]) d[j] = 'e';
		}
		for(int j=curr; j<n; j++){
			if(d[j]=='n' && len[j] >= len[curr]) break;
			if(d[j]=='y' && len[j] >= len[curr]) d[j] = 'e';
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}
