#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
template <class T>
T Abs(const T &x) {
  return (x < 0 ? -x : x);
}
const int INF = (int)1e9 + 7;
pair<int, int> need[17];
int redMask, blueMask, n;
int maxBlue[(1LL << (17)) + 3][17 * 17];
void init(void) {
  scanf("%d", &n);
  for (int i = 0, _n = (n); i < _n; i = i + 1) {
    char s[3];
    scanf("%s", s);
    int r, b;
    scanf("%d%d", &r, &b);
    if (s[0] == 'R')
      redMask |= (1LL << (i));
    else
      blueMask |= (1LL << (i));
    need[i] = make_pair(r, b);
  }
}
void process(void) {
  memset(maxBlue, -1, sizeof maxBlue);
  maxBlue[0][0] = 0;
  for (int i = 0, _n = ((1LL << (n))); i < _n; i = i + 1) {
    int numRed = __builtin_popcountll(i & redMask);
    int numBlue = __builtin_popcountll(i & blueMask);
    for (int j = 0, _n = (n * n + 1); j < _n; j = j + 1)
      if (maxBlue[i][j] >= 0)
        for (int k = 0, _n = (n); k < _n; k = k + 1)
          if (!(((i) >> (k)) & 1)) {
            int red = j + min(need[k].first, numRed);
            int blue = maxBlue[i][j] + min(need[k].second, numBlue);
            maximize(maxBlue[i | (1LL << (k))][red], blue);
          }
  }
  int res = INF;
  int sumRed = 0, sumBlue = 0;
  for (int i = 0, _n = (n); i < _n; i = i + 1) {
    sumRed += need[i].first;
    sumBlue += need[i].second;
  }
  for (int j = 0, _n = (n * n + 1); j < _n; j = j + 1)
    if (maxBlue[(1LL << (n)) - 1][j] >= 0) {
      int totRed = sumRed - j;
      int totBlue = sumBlue - maxBlue[(1LL << (n)) - 1][j];
      minimize(res, max(totRed, totBlue));
    }
  printf("%d\n", res + n);
}
int main(void) {
  init();
  process();
  return 0;
}
