#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 16) + 5, maxm = 125;
int n, f[maxn][maxm], sa[maxn], sb[maxn], va, vb;
struct node {
  int id, r, b;
} a[20];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char ch = getchar();
    while (ch != 'R' && ch != 'B') ch = getchar();
    a[i].id = (ch == 'B');
    scanf("%d%d", &a[i].r, &a[i].b);
  }
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 1; j <= n; j++)
      if (i & (1 << j - 1)) {
        if (a[j].id == 0)
          sa[i]++;
        else
          sb[i]++;
        ;
      }
  }
  for (int i = 1; i <= n; i++) va += a[i].r, vb += a[i].b;
  memset(f, 255, sizeof(f));
  f[0][0] = 0;
  for (int i = 0; i < (1 << n) - 1; i++) {
    for (int j = 0; j <= n * (n - 1) / 2; j++)
      if (f[i][j] != -1) {
        for (int k = 1; k <= n; k++)
          if (!(i & (1 << k - 1))) {
            int p = (i | (1 << k - 1));
            f[p][j + min(sa[i], a[k].r)] =
                max(f[p][j + min(a[k].r, sa[i])], f[i][j] + min(sb[i], a[k].b));
          }
      }
  }
  int ans = (1 << 30);
  for (int i = 0; i <= n * (n - 1) / 2; i++)
    if (f[(1 << n) - 1][i] != -1) {
      ans = min(ans, max(va - i, vb - f[(1 << n) - 1][i]) + n);
    }
  printf("%d\n", ans);
  return 0;
}
