#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
int n, suma, sumb, a[17], b[17];
int ca[1 << 16], cb[1 << 16], f[1 << 16][126];
int main() {
  n = read();
  int maxst = (1 << n) - 1;
  for (register int i = (0); i <= (n - 1); ++i) {
    char ch;
    while (!isupper(ch = getchar()))
      ;
    a[i] = read(), b[i] = read();
    suma += a[i], sumb += b[i];
    for (register int j = (0); j <= (maxst); ++j)
      if (j >> i & 1) {
        if (ch == 'R')
          ca[j]++;
        else
          cb[j]++;
      }
  }
  memset(f, -1, sizeof f);
  f[0][0] = 0;
  for (register int S = (0); S <= (maxst); ++S)
    for (register int j = (0); j <= (122); ++j)
      if (f[S][j] != -1)
        for (register int i = (0); i <= (n - 1); ++i) {
          if (S >> i & 1) continue;
          int T = S | (1 << i);
          int ma = min(a[i], ca[S]), mb = min(b[i], cb[S]);
          f[T][j + ma] = max(f[T][j + ma], f[S][j] + mb);
        }
  int res = 0x3f3f3f3f;
  for (register int i = (0); i <= (122); ++i)
    if (~f[maxst][i]) res = min(res, max(suma - i, sumb - f[maxst][i]));
  cout << res + n;
}
