#include <bits/stdc++.h>
using namespace std;
inline void rd(int& x) {
  static char ch;
  while (!isdigit(ch = getchar()))
    ;
  for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
}
char ch;
int n, i, j, dp[66000][260], to[66000], r[20], b[20], tp[20], er[20];
long long myr, myb, ans;
struct data {
  int r, b;
} sum[66000];
int main() {
  rd(n);
  for (i = 0; i < n; i++) {
    while ((ch = getchar()) != 'R' && ch != 'B')
      ;
    tp[i] = ch == 'R' ? 0 : 1;
    rd(r[i]), rd(b[i]);
    if (r[i] > 16) myr += r[i] - 16, r[i] = 16;
    if (b[i] > 16) myb += b[i] - 16, b[i] = 16;
  }
  for (i = 1, j = 0; j <= n; i <<= 1, j++) to[i] = j, er[j] = i;
  for (int k = 1; k < er[n]; k++) {
    sum[k] = sum[k - (k & -k)];
    if (tp[to[k & -k]])
      sum[k].b++;
    else
      sum[k].r++;
  }
  memset(dp, 0x7f, sizeof(dp));
  dp[0][0] = 0;
  for (i = 0; i < 1 << n; i++)
    for (int j = 0; j <= 256; j++)
      if (dp[i][j] < 2000000000) {
        for (int k = 0; k < n; k++)
          if (!(er[k] & i))
            dp[i | er[k]][j + max(0, r[k] - sum[i].r)] =
                min(dp[i | er[k]][j + max(0, r[k] - sum[i].r)],
                    dp[i][j] + max(0, b[k] - sum[i].b));
      }
  for (ans = 1 << 30, i = 0; i < 260; i++)
    ans = min(ans, max(myr + i, myb + dp[er[n] - 1][i]));
  printf("%I64d", ans + n);
}
