#include <bits/stdc++.h>
using namespace std;
struct ooxx {
  int k, x, y;
} a[100];
int alla, allb, dp[250000][121], n;
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  int s = 1 << n;
  for (int i = 0; i < s; ++i) dp[i][0] = 0;
  for (int i = 0; i < n; ++i) {
    char x = getchar();
    while ((x != 'R') && (x != 'B')) x = getchar();
    scanf("%d%d", &a[i].x, &a[i].y), alla += a[i].x, allb += a[i].y;
    if (x == 'R')
      a[i].k = 1;
    else
      a[i].k = 0;
  }
  for (int i = 0; i < s; ++i) {
    int nowa = 0, nowb = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        if (a[j].k == 1)
          nowa++;
        else
          nowb++;
      }
    }
    for (int j = 0; j <= 120; ++j) {
      for (int k = 0; k < n; ++k) {
        if (i & (1 << k)) continue;
        if (dp[i][j] == -1) continue;
        dp[i | (1 << k)][j + min(nowa, a[k].x)] =
            max(dp[i | (1 << k)][j + min(nowa, a[k].x)],
                dp[i][j] + min(nowb, a[k].y));
      }
    }
  }
  int ans = 1000000000;
  for (int i = 0; i <= 120; ++i)
    if (dp[s - 1][i] != -1) ans = min(ans, max(allb - dp[s - 1][i], alla - i));
  return printf("%d", ans + n), 0;
}
