#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[1 << 17][126];
long long cnta[1 << 17], cntb[1 << 17];
long long t[20], a[20], b[20], suma, sumb;
char op[2];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", op, &a[i], &b[i]);
    if (op[0] == 'R') t[i] = 0;
    if (op[0] == 'B') t[i] = 1;
    suma += a[i];
    sumb += b[i];
  }
  for (int i = 0; i < (1 << n); i++) {
    int ca = 0, cb = 0;
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        if (!t[j])
          ca++;
        else
          cb++;
      }
    }
    cnta[i] = ca, cntb[i] = cb;
  }
  memset(dp, -0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j <= 120; j++) {
      for (int k = 0; k < n; k++) {
        if (!(i >> k & 1)) {
          dp[i + (1 << k)][j + min(cnta[i], a[k])] =
              max(dp[i + (1 << k)][j + min(cnta[i], a[k])],
                  dp[i][j] + min(b[k], cntb[i]));
        }
      }
    }
  }
  long long ans = 1e18;
  for (int j = 0; j <= 120; j++) {
    ans = min(ans, max(sumb - dp[(1 << n) - 1][j], suma - j));
  }
  cout << ans + n << '\n';
}
