#include <bits/stdc++.h>
using namespace std;
long long f[(1 << 16)][300];
long long n, add;
char type[20];
long long a[20], b[20], sumA, sumB;
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> type[i] >> a[i] >> b[i];
    sumA += a[i];
    sumB += b[i];
  }
  for (long long i = 0; i < (1 << n); i++)
    for (long long x = 0; x <= n * n; x++) f[i][x] = -1e9;
  f[0][0] = 0;
  for (long long i = 0; i < (1 << n); i++)
    for (long long x = 0; x <= n * n; x++) {
      long long discountA = 0;
      long long discountB = 0;
      for (long long j = 0; j < n; j++) {
        if ((1 << j) & i) {
          if (type[j] == 'R') discountA++;
          if (type[j] == 'B') discountB++;
        }
      }
      for (long long j = 0; j < n; j++) {
        if (((1 << j) & i) == 0) {
          long long resA = min(a[j], discountA);
          long long resB = min(b[j], discountB);
          f[i | (1 << j)][x + resA] =
              max(f[i | (1 << j)][x + resA], f[i][x] + resB);
        }
      }
    }
  long long ans = 1e15;
  for (long long x = 0; x <= n * n; x++) {
    ans = min(ans, max(sumA - x, sumB - f[(1 << n) - 1][x]));
  }
  cout << ans + n;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
