#include <bits/stdc++.h>
const int inf = 0x3f3f3f;
int f[1 << 17][151], n, l[20], a[20], r[20], b[20], resr, resb, size, maxn,
    tr[1 << 17], tb[1 << 17], ans;
char op[20][2];
inline int min(int a, int b) { return a > b ? b : a; }
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  for (int i = 1; i < 20; ++i) l[i] = 1 << i - 1;
  scanf("%d", &n);
  size = 1 << n;
  maxn = 120;
  for (int i = 1; i <= n; ++i) {
    scanf("%s%d%d", op[i], &r[i], &b[i]);
    resr += r[i];
    resb += b[i];
  }
  for (int i = 0; i < size; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i & l[j]) {
        tr[i] += (op[j][0] == 'R' ? 1 : 0);
        tb[i] += (op[j][0] == 'B' ? 1 : 0);
      }
    }
  }
  memset(f, -inf, sizeof f);
  f[0][0] = 0;
  for (int i = 0; i < size; ++i) {
    for (int j = 0; j < maxn; ++j) {
      if (f[i][j] != -inf) {
        for (int k = 1; k <= n; ++k) {
          if (!(i & l[k])) {
            int nr, nb;
            nr = min(r[k], tr[i]);
            nb = min(b[k], tb[i]);
            f[i | l[k]][j + nr] = max(f[i | l[k]][j + nr], f[i][j] + nb);
          }
        }
      }
    }
  }
  ans = max(resr, resb);
  for (int i = 0; i <= maxn; ++i) {
    if (f[size - 1][i] != -inf) {
      ans = min(ans, max(resr - i, resb - f[size - 1][i]));
    }
  }
  printf("%d", ans + n);
  return 0;
}
