#ifndef __APPLE__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <vector>
#include <set>
#include "map"
#include "iomanip"
#include "cassert"
#include "numbers"
#include "random"
#endif
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
typedef long double ld;
const int nm = 1000007;
const int N = 2000*500+1;
typedef bitset<N> bts;
void solve() {
    int n;
    cin >> n;
    vector<array<int, 2>> op;
    op.push_back({1, 0});
    bts stpsb;
    bts onad;
    onad[0] = 1;
    bts ans;
    for (int i = 0; i < n; ++i) {
        char a;
        int b;
        string c;
        cin >> a >> b >> c;
        int tp = 0;
        if (a == '=')
            tp++;
        if (c == "async")
            tp += 2;
        op.push_back({tp, b});
        if (tp == 3) {
            stpsb[b] = 1;
        }
    }
    vector<int> gobk(n+2, -1);
    gobk[n+1] = 0;
    int ad = 0;
    for (int i = n; i >= 0; --i) {
        if (op[i][0] % 2 == 1) {
            break;
        } else {
            ad += op[i][1];
            gobk[i] = ad;
        }
    }
    for (int i = 0; i <= n; ++i) {
        if (op[i][0] % 2 == 1 and gobk[i+1] != -1) {
            ans |= onad << (op[i][1]+gobk[i+1]);
            //cerr << op[i][1] <<" " << gobk[i] << '\n';
        }
        if (gobk[i] != -1) {
            ans |= stpsb << gobk[i];
        }
        if (op[i][0] == 2) {
            stpsb |= stpsb << op[i][1];
            onad |= onad << op[i][1];
        }
    }
    ans |= stpsb;
    int res = 0;
    for (int i = 0; i < N; ++i) {
        res += ans[i];
    }
    cout << res << '\n';
}
signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int t = 1;
    //cin >> t;
    while (t--)
        solve();
}
/*

 */