Example

Input

3
y 7
y 6
n 5


Output

1
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	char buf[2];
	int length;
	bool erased;
};

struct Data{
	Data(int arg_index,int arg_length){
		index = arg_index;
		length = arg_length;
	}
	bool operator<(const struct Data &arg) const{
		if(length != arg.length){
			return length > arg.length;
		}else{
			return index > arg.index;
		}
	};

	int index,length;
};

int main(){

	int N;
	scanf("%d",&N);

	Info info[N];

	priority_queue<Data> Q;

	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].buf,&info[i].length);
		info[i].erased = false;

		if(info[i].buf[0] == 'y'){
			Q.push(Data(i,info[i].length));
		}
	}

	int ans = 0,index;

	while(!Q.empty()){
		index = Q.top().index;
		Q.pop();

		if(info[index].erased)continue;

		info[index].erased = true;
		ans++;

		for(int upper = index-1; upper >= 0; upper--){
			if(info[upper].buf[0] == 'n' && info[upper].length >= info[index].length)break;
			else if(info[upper].buf[0] == 'y' && info[upper].erased == false && info[upper].length >= info[index].length){
				info[upper].erased = true;
			}
		}

		for(int under = index+1; under <= N-1; under++){
			if(info[under].buf[0] == 'n' && info[under].length >= info[index].length)break;
			else if(info[under].buf[0] == 'y' && info[under].erased == false && info[under].length >= info[index].length){
				info[under].erased = true;
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}