#include <bits/stdc++.h>
using namespace std;
const int maxn = 16;
const int inf = 1e9 + 7;
char color[maxn];
int n;
int dp[1 << maxn][2][maxn * maxn + 1], red[maxn], blue[maxn];
int total_red, total_blue;
pair<int, int> get_available_cards(int mask) {
  pair<int, int> ret(0, 0);
  for (int i = 0; i < n; ++i) {
    if (mask & (1 << i)) {
      if (color[i] == 'R')
        ++ret.first;
      else
        ++ret.second;
    }
  }
  return ret;
}
int calc(int mask, int non_null, int amount) {
  if (mask == (1 << n) - 1) return 0;
  int& ref = dp[mask][non_null][amount];
  if (ref == -1) {
    ref = inf;
    pair<int, int> cards = get_available_cards(mask);
    int have_red = cards.first;
    int have_blue = cards.second;
    for (int i = 0; i < n; ++i) {
      if (!(mask & (1 << i))) {
        int need_red = max(0, red[i] - (non_null == 0) * amount - have_red);
        int need_blue = max(0, blue[i] - (non_null == 1) * amount - have_blue);
        int step_cost = max(need_red, need_blue);
        int after_red =
            amount * (non_null == 0) + step_cost - max(0, red[i] - have_red);
        int after_blue =
            amount * (non_null == 1) + step_cost - max(0, blue[i] - have_blue);
        ref = min(ref, step_cost + calc(mask | (1 << i), after_red ? 0 : 1,
                                        after_red ? after_red : after_blue));
      }
    }
  }
  return ref;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(dp, 0xff, sizeof(dp));
  cin >> n;
  total_red = total_blue = 0;
  for (int i = 0; i < n; ++i) {
    cin >> color[i] >> red[i] >> blue[i];
    total_red += max(0, red[i] - n);
    total_blue += max(0, blue[i] - n);
    red[i] = min(n, red[i]);
    blue[i] = min(n, blue[i]);
  }
  int ans = n + max(total_red, total_blue);
  int other;
  if (total_red > total_blue)
    other = calc(0, 1, min(n * n, total_red - total_blue));
  else
    other = calc(0, 0, min(n * n, total_blue - total_red));
  cout << ans + other << endl;
}
