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

using bs = bitset<1000001>;

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N;
	cin >> N;
	vector<tuple<string, int, string> > ops;
	for(int i = 0; i < N; i++){
		string type;
		int v;
		string sync;
		cin >> type >> v >> sync;
		ops.push_back({type, v, sync});
	}
	ops.insert(ops.begin(), {"=", 0, "sync"});
	N = (int)ops.size();
	int last_set = N-1;
	while(get<0>(ops[last_set]) != "=") last_set--;

	bs ans;
	bs prv; prv[0] = 1;
	for(int i = 0; i < last_set; i++){
		if(get<0>(ops[i]) == "+" && get<2>(ops[i]) == "async"){
			prv |= (prv << get<1>(ops[i]));
		}
	}
	int suff_add = 0;
	for(int i = last_set+1; i < N; i++){
		if(get<0>(ops[i]) == "+"){
			suff_add += get<1>(ops[i]);
		}
	}
	if(get<2>(ops[last_set]) == "sync"){
		ans = ans | (prv << suff_add << get<1>(ops[last_set]));
	}
	bs prv_set;
	for(int i = 0; i <= last_set; i++){
		if(get<0>(ops[i]) == "=" && get<2>(ops[i]) == "async"){
			prv_set |= (prv << get<1>(ops[i]));
		}
	}
	ans = ans | (prv_set << suff_add);
	for(int i = last_set+1; i < N; i++){
		if(get<0>(ops[i]) == "+"){
			suff_add -= get<1>(ops[i]);
			if(get<2>(ops[i]) == "async"){
				prv_set |= (prv_set << get<1>(ops[i]));
			}
		}
		ans = ans | (prv_set << suff_add);
	}
	cout << (ans.count()) << '\n';
}
