#include <bits/stdc++.h>

using namespace std;
//#define int long long
mt19937 rnd;
#define app push_back
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0)
#else
#define debug(...)
#define debugv(v)
#endif
#define lob(a,x) lower_bound(all(a),x)
#define upb(a,x) upper_bound(all(a),x)
#define print(x) cout<<(x)<<'\n'
#define suma(a) accumulate(all(a),0LL)
#define maxpos(a) max_element(all(a))-a.begin()
#define minpos(a) min_element(all(a))-a.begin()
#define maxa(a) *max_element(all(a))
#define mina(a) *min_element(all(a))
pair<int,vector<int> > read()
{
    int n;cin>>n;vector<int> a(n);for(int &x:a) {cin>>x;} return {n,a};
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    ++n;
    vector<char> c(n);vector<int> val(n);vector<string> typ(n);
    c[0]='=';val[0]=0;typ[0]="sync";
    for(int i=1;i<n;++i) {
        cin>>c[i]>>val[i]>>typ[i];
    }
    int s=accumulate(all(val),0LL)+1;
    int ls=n-1;while(c[ls]!='=') {--ls;}
    vector<int> ans(s);
    vector<int> h(s);h[0]=1;
    for(int i=0;i<ls;++i) {
        if(c[i]=='+' && typ[i]=="async") {
            for(int j=s-val[i]-1;j>=0;--j) {
                h[j+val[i]] |= h[j];
            }
        }
    }
    int shift=0;for(int i=ls+1;i<n;++i) {shift+=val[i];}
    int shift1=shift+val[ls];
    for(int j=s-shift1-1;j>=0;--j) ans[j+shift1]|=h[j];
    vector<int> okk(s);
    for(int i=0;i<=ls;++i) {
        if(c[i]=='=' && typ[i]=="async") {
            okk[val[i]]=1;
        }
    }
    for(int i=0;i<=ls;++i) {
        if(c[i]=='+' && typ[i]=="async") {
            for(int j=s-val[i]-1;j>=0;--j) {
                okk[j+val[i]] |= okk[j];
            }
        }
    }
    for(int i=ls;i<n;++i) {
        if(i!=ls) {shift-=val[i];}
        if(i!=ls && typ[i]=="async") {
            for(int j=s-val[i]-1;j>=0;--j) {
                okk[j+val[i]] |= okk[j];
            }
        }
        for(int j=s-shift-1;j>=0;--j) ans[j+shift]|=okk[j];
    }
    cout<<accumulate(all(ans),0LL);
    return 0;
}
