Example

Input

3
y 7
y 6
n 5


Output

1
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

signed main(){
	int n;
	while(cin>>n,n){
		vvi in;
		in.pb({0,inf});
		rep(i,n){
			string c;int a;
			cin>>c>>a;
			a*=2;
			if(c=="n")a++;
			in.pb({c=="y",a});
		}
		in.pb({0,inf});
		rep(i,in.size()-1){
			if(in[i][0]==in[i+1][0]){
				if(in[i][0])cmin(in[i][1],in[i+1][1]);
				if(!in[i][0])cmax(in[i][1],in[i+1][1]);
				in.erase(in.begin()+i+1);
				i--;
			}
		}
		int out=0;
		while(in.size()>=2){
			int mi=inf,t;
			rep(i,in.size())if(mi>in[i][1]){
				mi=in[i][1];
				t=i;
			}
			if(in[t][0]){
				out++;
				in.erase(in.begin()+t);
				t--;
				cmax(in[t][1],in[t+1][1]);
				in.erase(in.begin()+t+1);
			}else{
				in.erase(in.begin()+t);
				t--;
				cmin(in[t][1],in[t+1][1]);
				in.erase(in.begin()+t+1);
			}
		}
		cout<<out<<endl;
		break;
	}
}






