///////////////////////////////    _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <cfloat>
#include <memory>
#include <chrono>
#include <random>
#include <climits>
#include <limits>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <stack>
#include <tuple>
#include <queue>
#include <ctime>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 2005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
// mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
mt19937 myrand(373);

int n;

char tp[N];
int v[N];
string s[N];

bitset <N * 500> B, T, O;
bitset <N * 500> B2;

void print(bitset <N * N>& x) {
  for (int i = 0; i < N * N; i++) {
    if (x[i]) {
      cout << i << " ";
    }
  }
  cout << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;

  vector <int> vals;
  vector <int> equals;
  int last_equal = -1;

  for (int i = 1; i <= n; i++) {
    cin >> tp[i] >> v[i] >> s[i];

    if (s[i] == "async") {
      if (tp[i] == '+') {
        vals.push_back(v[i]);
      } else {
        equals.push_back(i);
      }
      continue;
    }

    if (tp[i] == '=') {
      last_equal = i;
      continue;
    }
  }

  vector <int> suf(n + 2, 0);
  suf[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    suf[i] = suf[i + 1];
    if (tp[i] == '+') {
      suf[i] += v[i];
    }
  }

  if (last_equal == -1 && (int)equals.size() == 0) {
    cout << 1 << endl;
    return 0;
  }

  int max_index = -1;

  if (last_equal != -1) {
    if ((int)equals.size() == 0 || last_equal >= equals.back()) {
      max_index = last_equal + 1;

      int sum = v[last_equal];
      for (int j = last_equal + 1; j <= n; j++) {
        if (tp[j] == '+') {
          sum += v[j];
        }
      }

      O[sum] = 1;
      for (int j = 1; j < max_index; j++) {
        if (tp[j] == '+' && s[j] == "async") {
          O |= (O << v[j]);
        }
      }

      // print(O);

      T |= O;
    }
  }

  if (max_index == -1) {
    max_index = equals.back() + 1;
  }

  B[0] = 1;
  for (int i = 1; i < max_index; i++) {
    if (tp[i] == '+' && s[i] == "async") {
      B |= (B << v[i]);
    }
  }
  
  set <int> equal_values;
  for (auto ind: equals) {
    equal_values.insert(v[ind]);
  }

  for (int i = max_index; i <= n; i++) {
    assert(tp[i] == '+');

    if (s[i] == "async") {
      B |= (B << v[i]);
      // print(B);
      continue;
    }

    for (int x: equal_values) {
      int current_x = x + suf[i];
      // cout << current_x << " ";
      T |= (B << current_x);
    }
  }
  // cout << endl;

  for (int x: equal_values) {
    T |= (B << x);
  }

  // print(T);
  
  cout << T.count() << endl;
  return 0;
}
