#include <bits/stdc++.h>
using namespace std;
char c[25];
int r[25], b[25], dp[70005][405];
inline void upd(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  int n, rsum = 0, bsum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%*c%c%d%d", c + i, r + i, b + i);
    rsum += r[i];
    bsum += b[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < 1 << n; i++) {
    int rcnt = 0, bcnt = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) (c[j] == 'R' ? rcnt : bcnt)++;
    }
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) continue;
      for (int k = 0; k <= 300; k++) {
        if (~dp[i][k])
          upd(dp[i | (1 << j)][k + min(rcnt, r[j])],
              dp[i][k] + min(bcnt, b[j]));
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i <= 300; i++) {
    if (~dp[(1 << n) - 1][i])
      ans = min(ans, max(rsum - i, bsum - dp[(1 << n) - 1][i]));
  }
  printf("%d\n", n + ans);
  return 0;
}
