#include <bits/stdc++.h>
using namespace std;
constexpr int N = 17;
constexpr int M = 1 << 16;
constexpr int MOD = 1e9 + 7;
int n, r[N], b[N], abi[M], ghermez[M], dp[M][N * N], R, ans = 1e9;
char c[N];
int main() {
  ios_base::sync_with_stdio(false);
  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];
  for (int mask = 1; mask < (1 << n); mask++) {
    abi[mask] = abi[mask ^ (1 << __builtin_ctz(mask))] +
                (c[__builtin_ctz(mask)] == 'B' ? 1 : 0);
    ghermez[mask] = ghermez[mask ^ (1 << __builtin_ctz(mask))] +
                    (c[__builtin_ctz(mask)] == 'R' ? 1 : 0);
  }
  memset(dp, 63, sizeof(dp));
  dp[0][0] = 0;
  for (int mask = 1; mask < (1 << n); mask++) {
    for (int i = 0; i <= n * n; i++) {
      for (int j = 0; j < n; j++) {
        if (mask & (1 << j)) {
          int msk = mask ^ (1 << j);
          int diff = r[j] - max(0, r[j] - ghermez[msk]);
          if (i >= diff)
            dp[mask][i] =
                min(dp[mask][i], dp[msk][i - diff] + max(0, b[j] - abi[msk]));
        }
      }
    }
  }
  for (int i = 0; i <= n * n; i++)
    ans = min(ans, max(dp[(1 << n) - 1][i], R - i));
  cout << ans + n << '\n';
  return 0;
}
