Example

Input

3
y 7
y 6
n 5


Output

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

const int N=1010;
int n,h[N],ty[N],ans=0;
bool rm[N];

void gao(int l,int r,int lsh)
{
	if(l>r) return;
	int mxh=0;
	for(int i=l;i<=r;i++)
		if(ty[i]) mxh=max(mxh,h[i]);
	vector<int> pos;
	pos.push_back(l-1);
	for(int i=l;i<=r;i++)
		if(ty[i]&&h[i]==mxh) pos.push_back(i);
	pos.push_back(r+1);
	if(pos.size()==2) goto calc;
	for(int i=1;i<pos.size();i++)
		gao(pos[i-1]+1,pos[i]-1,mxh);
	calc: int mnh=N+1;
	for(int i=l;i<=r;i++)
		if(!ty[i]&&!rm[i]) mnh=min(mnh,h[i]);
	if(mnh>lsh) return;
	for(int i=l;i<=r;i++) rm[i]=1;
	ans++;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		static char ts[5];
		scanf("%s%d",ts,h+i);
		if(*ts=='n') ty[i]=1;
	}
	gao(1,n,N);
	printf("%d\n",ans);
	return 0;
}
