#include <iostream>
#include <vector>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <bitset>
#include <cassert>

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("Ofast")//Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

using namespace std;
mt19937 rnd(179);
const int MAXSZ = 2000 * 500 + 1;
const int MAXN = 2001;
vector<int> nw[MAXN];
int n;
vector<tuple<char, int, string>> inp;

void input() {
    cin >> n;
    inp.assign(n + 1, {});
    inp[0] = make_tuple('=', 0, "sync");
    for (int i = 1 ;i <= n; i++) {
        cin >> get<0>(inp[i]) >> get<1>(inp[i]) >> get<2>(inp[i]);
    }
    n++;
}

int solve() {
    bitset<MAXSZ> res;
    int sumAll = 0;
    for (int i = 0;i < (int)inp.size(); i++) {
        if (get<0>(inp[i]) == '+') sumAll += get<1>(inp[i]);
    }
    assert(sumAll <= MAXSZ);
    bitset<MAXSZ> temp, ntemp;
    temp[0] = 1;
    int lst = -1;
    for (int i = 0; i < (int)inp.size(); i++) if (get<0>(inp[i]) == '=') {
        lst = i;
    }
    for (int i = 0; i < (int)inp.size(); i++) {
        if (get<0>(inp[i]) == '+') sumAll -= get<1>(inp[i]);
        if (get<2>(inp[i]) == "async" && get<0>(inp[i]) == '+') {
            ntemp = temp | (temp << (get<1>(inp[i])));
            auto bts = temp ^ ntemp;
            if (bts.any() && i > lst) {
                for (auto x = bts._Find_first(); x < MAXSZ; x = bts._Find_next(x)) {
                    nw[i].push_back((int)x);
                }
            }
            swap(temp, ntemp);
            // for (int x : nw[i]) temp[x] = 1;
        }
        if (i == lst && get<0>(inp[i]) == '=' && get<2>(inp[i]) == "sync") {
            res |= (temp << (sumAll + get<1>(inp[i])));
        }
    }
    bitset<MAXSZ> temp2 = temp;
    sumAll = 0;
    for (int i = (int)inp.size() - 1; i >= 0; i--) {
        if (get<0>(inp[i]) == '+' && i > lst) {
            sumAll += get<1>(inp[i]);
            if (get<2>(inp[i]) == "async") for (int x : nw[i]) temp[x] = 0;
            temp2 |= (temp << sumAll);
        }
        if (get<0>(inp[i]) == '=' && get<2>(inp[i]) == "async") {
            res |= (temp2 << get<1>(inp[i]));
        }
    }
    return res.count();
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(30);

    int t = 1;
    // cin >> t;
    while (t--) {
        input();
        int out = solve();
        cout << out << '\n';
    }
}
