#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> V;
int type[18], r[18], b[18];
inline int F(vector<int> &ord) {
  int r_tok = 0, b_tok = 0;
  int r_card = 0, b_card = 0;
  int r_needed, b_needed;
  int add, ret = 0, x;
  for (int i = 0; i < n; i++) {
    x = ord[i];
    r_needed = max(r[x] - r_card, 0);
    b_needed = max(b[x] - b_card, 0);
    add = max(r_needed - r_tok, b_needed - b_tok);
    ret += add;
    r_tok += add;
    b_tok += add;
    if (type[x] == 0)
      r_card++;
    else
      b_card++;
    r_tok -= r_needed;
    b_tok -= b_needed;
  }
  ret += n;
  return ret;
}
char cmd[5];
int main() {
  cin >> n;
  V.resize(n);
  iota(V.begin(), V.begin() + n, 0);
  for (int i = 0; i < n; i++) {
    scanf("%s %d %d", cmd, &r[i], &b[i]);
    if (cmd[0] == 'R')
      type[i] = 0;
    else
      type[i] = 1;
  }
  if (n == 1) {
    cout << F(V) << endl;
    return 0;
  }
  double temp;
  double mul;
  int lim;
  int a, b, e, ne;
  int ans = 2000000000;
  double cur = 999999999;
  for (int lala = 0; lala < 10; lala++) {
    iota(V.begin(), V.begin() + n, 0);
    temp = cur - rand();
    mul = 0.9997;
    lim = 500000;
    for (int it = 0; it < lim; it++) {
      e = F(V);
      a = rand() % n;
      b = rand() % n;
      swap(V[a], V[b]);
      ne = F(V);
      swap(V[a], V[b]);
      if (ne < e) {
        swap(V[a], V[b]);
      } else {
        double p = exp((e - ne) / temp);
        if (p > (rand() / (double)RAND_MAX)) swap(V[a], V[b]);
      }
      if (temp > 1e-20) temp *= mul;
    }
    ans = min(ans, F(V));
  }
  cout << ans << endl;
  return 0;
}
