#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long sz = (1 << 16);
char tp[maxn];
long long r[maxn], b[maxn];
long long dp[sz][2][165];
long long ans = 1e18;
int32_t main() {
  long long n = in();
  long long A = 0, B = 0;
  for (long long i = 0; i < n; i++) {
    cin >> tp[i] >> r[i] >> b[i];
    if (r[i] >= n) A += r[i] - n + 1, r[i] = n - 1;
    if (b[i] >= n) B += b[i] - n + 1, b[i] = n - 1;
  }
  memset(dp, 63, sizeof dp);
  dp[0][0][0] = dp[0][1][0] = 0;
  for (long long mask = 1; mask < (1 << n); mask++) {
    long long red = 0, blue = 0;
    for (long long x = 0; x < n; x++)
      if (mask >> x & 1) red += tp[x] == 'R', blue += tp[x] == 'B';
    for (long long x = 0; x < n; x++) {
      if (mask >> x & 1) {
        long long premask = mask ^ (1 << x);
        red -= tp[x] == 'R', blue -= tp[x] == 'B';
        for (long long j = 0; j < 2; j++) {
          for (long long other = 0; other <= 160; other++) {
            if (dp[premask][j][other] >= 1e18) continue;
            long long redToken = j == 1 ? 0 : other;
            long long blueToken = other - redToken;
            long long newoperation = max(max(0ll, r[x] - red - redToken),
                                         max(0ll, b[x] - blue - blueToken));
            redToken += newoperation;
            blueToken += newoperation;
            redToken -= max(0ll, r[x] - red),
                blueToken -= max(0ll, b[x] - blue);
            if (max(redToken, blueToken) < 165)
              dp[mask][redToken == 0][max(redToken, blueToken)] =
                  min(dp[mask][redToken == 0][max(redToken, blueToken)],
                      dp[premask][j][other] + newoperation);
          }
        }
        red += tp[x] == 'R', blue += tp[x] == 'B';
      }
    }
  }
  for (long long j = 0; j < 2; j++)
    for (long long other = 0; other < 165; other++) {
      long long var =
          dp[(1 << n) - 1][j][other] +
          max(max(0ll, A - bool(j == 0) * other), max(0ll, B - j * other));
      ans = min(ans, var);
    }
  cout << ans + n << endl;
}
