#include <bits/stdc++.h>
using namespace std;
int main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  static int dp[1 << 16][555];
  int n;
  static char c[1 << 20];
  static int a[1 << 20];
  static int b[1 << 20];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> c[i] >> a[i] >> b[i];
  int sa = accumulate(a, a + n, 0);
  int sb = accumulate(b, b + n, 0);
  const int N = 1 << n;
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int mask = 0; mask < N; ++mask) {
    int fa = 0, fb = 0;
    for (int i = 0; i < n; ++i)
      if ((mask >> i) & 1) fa += c[i] == 'R', fb += c[i] == 'B';
    for (int k = 0; k < 130; ++k)
      if (dp[mask][k] >= 0)
        for (int i = 0; i < n; ++i)
          if (!((mask >> i) & 1))
            dp[mask ^ (1 << i)][k + min(a[i], fa)] =
                max(dp[mask ^ (1 << i)][k + min(a[i], fa)],
                    dp[mask][k] + min(b[i], fb));
  }
  int ans = 2e9 + 55;
  for (int i = 0; i <= 130; ++i)
    if (dp[N - 1][i] >= 0) ans = min(ans, max(sa - i, sb - dp[N - 1][i]));
  cout << ans + n << '\n';
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
