Example

Input

3
y 7
y 6
n 5


Output

1
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define REP(i,n) for(ll i=0; i<(n); ++i)
 
 
struct union_find{
	vector<ll> v;
	union_find(ll n) : v(n, -1){}
	ll find(ll x) { return (v[x] < 0) ? x : (v[x] = find(v[x]));}
	bool unite(ll x, ll y){
		x = find(x); y = find(y);
		if(x==y) return false;
		if(-v[x] < -v[y]) swap(x,y);
		v[x] += v[y];
		v[y] = x;
		return true;
	}
	bool same(ll x, ll y) {return find(x) == find(y);}
	ll size(ll x) {return -v[find(x)];}
};
 
int main(){
	ll n;
	cin >> n;
	//
	ll MAX = 9000;
	vector<ll> deletable(n+2, MAX);
	//
	union_find uf(n+2);
	///
	vector<pair<ll,ll>> undeletable;
 
	ll deletable_i = 0;
	REP(i,n){
		char d;
		ll l;
		cin >> d >> l;
		if(d=='y'){
			deletable[deletable_i] = min(deletable[deletable_i], l);
		}else{
			undeletable.push_back(make_pair(l,undeletable.size()));
			deletable_i++;
		}
	}
 
	ll count = 0;
	auto undeletable_sorted = undeletable;
	sort(undeletable_sorted.begin(), undeletable_sorted.end());
	for(auto& x : undeletable_sorted){
		ll id = x.second; ll len = x.first;
		if(deletable[uf.find(id)] <= len){ count++; deletable[uf.find(id)] = MAX;}
		if(deletable[uf.find(id+1)] <= len) { count++; deletable[uf.find(id+1)] = MAX;}
		ll n_len = min(deletable[uf.find(id)], deletable[uf.find(id+1)]);
		uf.unite(id, id+1);
		deletable[uf.find(id)] = n_len;
	}
	if(deletable[uf.find(0)] != MAX ){
		count++;
	}
 
	cout << count << endl;
}