#include <bits/stdc++.h>
using namespace std;
int n;
string c[int(20)];
int r[int(20)], b[int(20)];
int count(int mask, char color) {
  int ans = 0;
  for (int s = 0, __R = n - 1; s <= __R; s++)
    if (!((mask >> s) & 1) && c[s][0] == color) ans++;
  return ans;
}
int f(int i, int j, int k) {
  if (!i) return 0;
  static int dp[1 << 16][2][(1 << 8) + 1];
  static bool mark[1 << 16][2][(1 << 8) + 1];
  auto& ans = dp[i][j][k];
  if (mark[i][j][k]) return ans;
  mark[i][j][k] = true;
  ;
  int R = count(i, 'R'), B = count(i, 'B');
  int rs = j ? k : 0, bs = j ? 0 : k;
  ans = 0x3f3f3f3f3f3f3f3fLL;
  for (int s = 0, __R = n - 1; s <= __R; s++)
    if ((i >> s) & 1) {
      int cr = max(0, r[s] - R), cb = max(0, b[s] - B);
      int fr = max(0, cr - rs), fb = max(0, cb - bs);
      int turns = max(fr, fb);
      int rs_ = rs + turns - cr, bs_ = bs + turns - cb;
      ans = min(ans, f(i & ~(1 << s), rs_ ? 1 : 0, max(rs_, bs_)) + turns);
    }
  return ans;
}
int main() {
  int B = 0, R = 0;
  cin >> n;
  for (int i = 0, __R = n - 1; i <= __R; i++) {
    cin >> c[i] >> r[i] >> b[i];
    B += max(0, b[i] - n);
    R += max(0, r[i] - n);
    b[i] = min(b[i], n);
    r[i] = min(r[i], n);
  }
  cout << f((1 << n) - 1, B > R ? 1 : 0, min(n * n, max(B, R) - min(B, R))) +
              max(B, R) + n
       << endl;
  return 0;
}
