#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  int a = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (; '0' <= c && c <= '9'; c = getchar())
    a = (a << 3) + (a << 1) + (c ^ 48);
  return a * f;
}
const int MaxN = 16;
int dp[1 << MaxN][MaxN * MaxN];
int R[1 << MaxN], B[1 << MaxN];
int r[MaxN], b[MaxN];
char inBuf[MaxN];
int main() {
  int n = readint();
  int allR = 0, allB = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", inBuf);
    if (*inBuf == 'R')
      R[1 << i] = 1;
    else
      B[1 << i] = 1;
    allR += (r[i] = readint());
    allB += (b[i] = readint());
  }
  memset(dp, -1, (1 << MaxN) * MaxN * MaxN << 2);
  dp[0][0] = 0;
  for (int S = 1; S < (1 << n); ++S) {
    R[S] = R[S - (S & -S)] + R[S & -S];
    B[S] = B[S - (S & -S)] + B[S & -S];
    for (int i = 0; i < n; ++i) {
      if (!(S >> i & 1)) continue;
      int w = R[S - (1 << i)];
      if (w > r[i]) w = r[i];
      int v = B[S - (1 << i)];
      if (v > b[i]) v = b[i];
      int xez = R[S] * (R[S] - 1) / 2 + B[S] * R[S];
      for (int j = xez; j >= w; --j)
        if (dp[S - (1 << i)][j - w] != -1)
          dp[S][j] = max(dp[S][j], dp[S - (1 << i)][j - w] + v);
    }
  }
  int ans = max(allB, allR);
  for (int i = 0; i < MaxN * MaxN; ++i)
    if (dp[(1 << n) - 1][i] != -1)
      ans = min(ans, max(allR - i, allB - dp[(1 << n) - 1][i]));
  printf("%d\n", ans + n);
  return 0;
}
