Example

Input

3
y 7
y 6
n 5


Output

1
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,l[1010];
	char d[1010];
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> d[i] >> l[i];
	d[0] = d[n + 1] = 'n';
	l[0] = l[n + 1] = INF;
	vector<P> vec;
	for(int i = 1;i <= n;i++){
		if(d[i] == 'y') vec.emplace_back(l[i],i);
	}
	sort(all(vec));
	bool used[1010] = {};
	int ans = 0;
	for(P p : vec){
		int v = p.second;
		if(used[v]) continue;
		int x = v - 1,y = v + 1;
		while(d[x] == 'y' || l[v] > l[x]) x--;
		while(d[y] == 'y' || l[v] > l[y]) y++;
		for(int j = x + 1;j <= y - 1;j++) used[j] = true;
		ans++;
	}
	cout << ans << endl;
}
