#include <bits/stdc++.h>
using namespace std;
const int maxn = 120;
char op[16][2];
int n, s, dp[1 << 16][121], ta[16], tb[16], ra[1 << 16], rb[1 << 16], resa,
    resb, res, na, nb;
int main() {
  scanf("%d", &n);
  s = 1 << n;
  for (int i = 0; i < n; ++i) {
    scanf("%s%d%d", op[i], &ta[i], &tb[i]);
    resa += ta[i];
    resb += tb[i];
  }
  for (int i = 0; i < s; ++i)
    for (int j = 0; j < n; ++j)
      if (i & (1 << j)) {
        ra[i] += op[j][0] == 'R' ? 1 : 0;
        rb[i] += op[j][0] == 'B' ? 1 : 0;
      }
  memset(dp, -1, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0; i < s; ++i)
    for (int j = 0; j <= maxn; ++j) {
      if (dp[i][j] == -1) continue;
      for (int k = 0; k < n; ++k) {
        if (i & (1 << k)) continue;
        na = min(ta[k], ra[i]);
        nb = min(tb[k], rb[i]);
        dp[i | (1 << k)][j + na] = max(dp[i | (1 << k)][j + na], dp[i][j] + nb);
      }
    }
  res = max(resa, resb);
  for (int i = 0; i <= maxn; ++i)
    if (dp[s - 1][i] != -1) res = min(res, max(resa - i, resb - dp[s - 1][i]));
  printf("%d\n", res + n);
  return 0;
}
