Example

Input

3
y 7
y 6
n 5


Output

1
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
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); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

typedef tuple<int, int, int> state; // length, yes:0 no:1, index

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi len(n), del(n);
	priority_queue<pii> que;
	REP(i, n)
	{
		char c; int a; cin >> c >> a;
		len[i] = a;
		del[i] = c == 'y';
		if (del[i]) que.emplace(-a, i);
	}
	vi ub(n, 1111), lb(n, -1);
	REP(i, n)
	{
		if (!del[i]) continue;
		FOR(j, i + 1, n)
		{
			if (!del[j] && len[j] >= len[i])
			{
				ub[i] = j;
				break;
			}
		}
	}
	REP(i, n)
	{
		if (!del[i]) continue;
		for(int j = i - 1; j >= 0; j--)
		{
			if (!del[j] && len[j] >= len[i])
			{
				lb[i] = j;
				break;
			}
		}
	}
	vector<bool> vis(n);
	int ans = 0;
	while (!que.empty())
	{
		int t = que.top().second;
		que.pop();
		if (vis[t]) continue;
		ans++;
		FOR(i, max(0, lb[t]), min(n, ub[t])) vis[i] = true;
	}
	cout << ans << endl;
	return 0;
}