#include <bits/stdc++.h>
using namespace std;
int dp[65550][2][300];
int r[20], b[20];
char c[20];
int n;
long long dfs(int p, int typ, long long rmd) {
  if (rmd > n * n) rmd = n * n;
  if (p == (1 << n) - 1) return 0;
  if (dp[p][typ][rmd] != -1) return dp[p][typ][rmd];
  int R = 0, B = 0;
  for (int e = 0, k = 1; e < n; e++, k <<= 1) {
    if (p & k) {
      if (c[e] == 'R')
        R++;
      else
        B++;
    }
  }
  for (int e = 0, k = 1; e < n; e++, k <<= 1) {
    if (p & k) continue;
    int pr = max(r[e] - R, 0);
    int pb = max(b[e] - B, 0);
    int kr = 0, kb = 0;
    if (typ == 0)
      kr = rmd;
    else
      kb = rmd;
    if (kr < pr) {
      kb += (pr - kr);
      kr = pr;
    }
    if (kb < pb) {
      kr += (pb - kb);
      kb = pb;
    }
    int cost = min(kr, kb);
    kr -= pr;
    kb -= pb;
    int pans = 0;
    if (kr != 0)
      pans = dfs(p + k, 0, kr);
    else
      pans = dfs(p + k, 1, kb);
    pans += cost;
    if (dp[p][typ][rmd] == -1 || dp[p][typ][rmd] > pans) dp[p][typ][rmd] = pans;
  }
  dp[p][typ][rmd]++;
  return dp[p][typ][rmd];
}
int main() {
  while (scanf("%d", &n) == 1) {
    long long remain_r = 0, remain_b = 0;
    for (int i = 0; i < n; i++) {
      char re[10];
      scanf("%s", re);
      c[i] = re[0];
      scanf("%d%d", &r[i], &b[i]);
      if (r[i] > n) {
        remain_r += (r[i] - n);
        r[i] = n;
      }
      if (b[i] > n) {
        remain_b += (b[i] - n);
        b[i] = n;
      }
    }
    memset(dp, -1, sizeof(dp));
    long long ans;
    if (remain_r > remain_b)
      ans = remain_r + dfs(0, 1, remain_r - remain_b);
    else
      ans = remain_b + dfs(0, 0, remain_b - remain_r);
    printf("%lld\n", ans);
  }
}
