#include <bits/stdc++.h>
using namespace std;
int n, r[17], b[17], R, B;
char c[17];
int dp[(1 << 16) + 10][16 * 16];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> r[i] >> b[i];
    R += r[i];
    B += b[i];
  }
  for (int mask = 0; mask < (1 << n); mask++)
    for (int i = 0; i < 16 * 16; i++) dp[mask][i] = -1e9;
  dp[0][0] = 0;
  for (int mask = 1; mask < (1 << n); mask++) {
    int pop = __builtin_popcount(mask);
    int red = 0, blue = 0;
    for (int i = 0; i < n; i++)
      if (mask & (1 << i)) c[i] == 'R' ? red++ : blue++;
    for (int val = 0; val <= (pop * (pop - 1)) / 2; val++) {
      for (int i = 0; i < n; i++) {
        if (mask & (1 << i)) {
          if (c[i] == 'R') {
            int me = val - min(r[i], red - 1);
            if (me >= 0) {
              dp[mask][val] =
                  max(dp[mask][val], dp[mask ^ (1 << i)][me] + min(b[i], blue));
            }
          } else {
            int me = val - min(r[i], red);
            if (me >= 0)
              dp[mask][val] = max(
                  dp[mask][val], dp[mask ^ (1 << i)][me] + min(b[i], blue - 1));
          }
        }
      }
    }
  }
  int answer = 1e9;
  for (int i = 0; i <= (n * (n - 1)) / 2; i++)
    answer = min(answer, max(R - i, B - dp[(1 << n) - 1][i]));
  cout << answer + n << '\n';
  return 0;
}
