#include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int long long
using ld = long double;

#define all(v) (v).begin(), (v).end()
#define db(x) cerr << #x << " = " << x << '\n'
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define sz(v) (int)((v).size())
#define pw(x) (1LL << (int)(x))
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define fe(x, y) for (auto &x: y)
#define fi first
#define se second

mt19937_64 rng(566);

ll rnd(ll l, ll r) {
    return rng() % (r - l + 1) + l;
}

template<typename T>
bool umn(T &a, T b) {
    return a > b ? a = b, 1 : 0;
}

template<typename T>
bool umx(T &a, T b) {
    return a < b ? a = b, 1 : 0;
}

template<typename T>
using ve = vector<T>;

using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double eps = 1e-8;
const ll mod = 1e9 + 8;
const int inf0 = 1e9 + 10;
const ll inf = 2e18 + 10;

void solve();

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LC
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

const int N = 2005;
const int M = 1e6 + 5;

#define sync aboba

int n;
char t[N];
int v[N];
bool sync[N];
bitset<M> ans;

bitset<M> dp;

void lastSyncAssignment() {
    int pos = -1;
    rf (i, n, 1) {
        if (t[i] == '=' && sync[i]) {
            pos = i;
            break;
        }
    }

    if (pos == -1) return;

    int sum = v[pos];
    fr (i, pos + 1, n) {
        if (!sync[i] && t[i] == '=') return;

        assert(t[i] == '+');
        sum += v[i];
    }

    dp.reset();
    dp[0] = 1;
    fr (i, 1, pos - 1) {
        if (t[i] == '+' && !sync[i]) {
            dp = dp | (dp << v[i]);
        }
    }
    ans |= dp << sum;
}

int suff[N];

void solve() {
    cin >> n;

    fr (i, 1, n) {
        string s;
        cin >> t[i] >> v[i] >> s;

        if (s[0] == 'a') sync[i] = false;
        else sync[i] = true;
    }

    rf (i, n + 1, 1) {
        t[i] = t[i - 1];
        v[i] = v[i - 1];
        sync[i] = sync[i - 1];
    }
    t[1] = '=';
    v[1] = 0;
    sync[1] = true;
    n++;

    lastSyncAssignment();

    int pos = n;
    rf (i, n, 1) {
        if (t[i] == '=') {
            pos = i;
            break;
        }
    }

    dp.reset();
    fr (i, 1, n) {
        if (t[i] == '=' && !sync[i]) {
            dp[v[i]] = 1;
        }
    }

    rf (i, n, 1) {
        suff[i] = t[i] == '+' ? v[i] : 0;
        suff[i] += suff[i + 1];
    }

    fr (i, 1, n) {
        if (t[i] == '+' && !sync[i]) {
            dp = dp | (dp << v[i]);
        }

        if (i > pos && sync[i]) {
            ans |= (dp << suff[i]);
        }
    }

    ans |= dp;

    // fr (i, 0, M - 1) {
    //     if (ans[i]) cout << i << " ";
    // }
    // cout << "\n";

    cout << ans.count() << "\n";
}
