#include <bits/stdc++.h>
using namespace std;
int n, allr, allb;
char op[23][2];
int ri[23], bi[23];
int bitr[1 << 23], bitb[1 << 23];
int f[1 << 17][130];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s%d%d", op[i], &ri[i], &bi[i]);
    allr += ri[i];
    allb += bi[i];
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j)
      if (i & (1 << j)) {
        bitr[i] += op[j][0] == 'R' ? 1 : 0;
        bitb[i] += op[j][0] == 'B' ? 1 : 0;
      }
  }
  memset(f, -1, sizeof f);
  f[0][0] = 0;
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < 130; ++j) {
      if (f[i][j] == -1) continue;
      for (int k = 0; k < n; ++k) {
        if (i & (1 << k)) {
          continue;
        }
        int tmpr = min(bitr[i], ri[k]);
        int tmpb = min(bitb[i], bi[k]);
        f[i | (1 << k)][j + tmpr] =
            max(f[i | (1 << k)][j + tmpr], f[i][j] + tmpb);
      }
    }
  }
  int ans = max(allr, allb);
  for (int i = 0; i < 130; ++i)
    if (f[(1 << n) - 1][i] != -1)
      ans = min(ans, max(allr - i, allb - f[(1 << n) - 1][i]));
  printf("%d\n", ans + n);
  return 0;
}
