#include <bits/stdc++.h>
using namespace std;
const int mxzt = (1 << 16) + 233;
int cr[23], cb[23], col[23];
short dl[23], tmpdl[23];
int i, j, k, n, m;
int ra, fh;
char rx;
inline int read() {
  rx = getchar(), ra = 0, fh = 1;
  while (rx < '0') rx == '-' && (fh = -1), rx = getchar();
  while (rx >= '0') ra = ra * 10 + rx - 48, rx = getchar();
  return ra * fh;
}
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  n = read();
  for (i = 1; i <= n; i++) {
    for (rx = getchar(); rx < 'A' || rx > 'Z'; rx = getchar())
      ;
    col[i] = rx;
    cr[i] = read(), cb[i] = read(), dl[i] = i;
  }
  srand(23333 + n);
  int smr, smb, rr, rb, tim, tmpt, ans = 1e9 + 233;
  int mx = 20000000 / max(20 - n, n);
  for (int tur = mx; tur; tur--) {
    memcpy(tmpdl + 1, dl + 1, n << 1);
    for (i = rand() % 7 + 1; i; i--)
      swap(dl[rand() % n + 1], dl[rand() % n + 1]);
    smr = smb = rr = rb = tim = 0;
    for (i = 1; i <= n; i++) {
      j = dl[i], rr -= max(0, cr[j] - smr), rb -= max(0, cb[j] - smb),
      tmpt = max(0, max(-rr, -rb)), rr += tmpt, rb += tmpt, tim += tmpt;
      if (col[j] == 'R')
        smr++;
      else
        smb++;
    }
    if (tim <= ans)
      ans = tim;
    else {
      if (pow(233333.0, 0.8 * (tim - ans)) > tur)
        memcpy(dl + 1, tmpdl + 1, n << 1);
    }
  }
  printf("%d\n", ans + n);
}
