/**
 *    author:  tourist
 *    created: 05.11.2025 22:39:14
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  n += 1;
  vector<bool> eq(n);
  vector<int> val(n);
  vector<bool> sync(n);
  eq[0] = true;
  val[0] = 0;
  sync[0] = true;
  for (int i = 1; i < n; i++) {
    char op;
    string type;
    cin >> op >> val[i] >> type;
    eq[i] = (op == '=');
    sync[i] = (type == "sync");
  }
  int last_eq = 0;
  for (int i = 1; i < n; i++) {
    if (eq[i]) {
      last_eq = i;
    }
  }
  const int N = int(1e6);
  bitset<N> sums;
  sums[0] = 1;
  for (int i = 0; i < last_eq; i++) {
    if (!eq[i] && !sync[i]) {
      sums |= sums << val[i];
    }
  }
  int sum_after = accumulate(val.begin() + last_eq + 1, val.end(), 0);
  bitset<N> adds;
  bitset<N> ans;
  adds |= sums << sum_after;
  ans |= adds << val[last_eq];
  for (int i = last_eq + 1; i < n; i++) {
    if (!sync[i]) {
      sums |= sums << val[i];
    }
    sum_after -= val[i];
    adds |= sums << sum_after;
  }
  for (int i = 0; i <= last_eq; i++) {
    if (eq[i] && !sync[i]) {
      ans |= adds << val[i];
    }
  }
  cout << ans.count() << '\n';
  return 0;
}
