#include <bits/stdc++.h>
using namespace std;
char read() {
  char ch = getchar();
  if (ch != 'R' && ch != 'B') ch = getchar();
  return ch;
}
int n, lim, sumr, sumb, ans;
char opt[20];
int ndr[20], ndb[20], saver[20], saveb[20];
int r, b, f[66000][150];
int main() {
  scanf("%d", &n);
  lim = (1 << n) - 1;
  for (int i = 0; i < n; i++) {
    opt[i] = read();
    scanf("%d%d", &ndr[i], &ndb[i]);
    sumr += ndr[i];
    sumb += ndb[i];
  }
  memset(f, 0xef, sizeof(f));
  f[0][0] = 0;
  for (int i = 0; i <= lim; i++) {
    r = 0, b = 0;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) {
        r += (opt[j] == 'R');
        b += (opt[j] == 'B');
      }
    for (int j = 0; j < n; j++) {
      saver[j] = min(ndr[j], r);
      saveb[j] = min(ndb[j], b);
    }
    for (int j = 0; j < n; j++)
      if (!(i & (1 << j)))
        for (int k = 0; k <= 130; k++)
          f[i | (1 << j)][k + saver[j]] =
              max(f[i | (1 << j)][k + saver[j]], f[i][k] + saveb[j]);
  }
  ans = 0x3f3f3f3f;
  for (int i = 0; i <= 130; i++)
    ans = min(ans, max(sumr - i, sumb - f[lim][i]));
  printf("%d", ans + n);
  return 0;
}
