#include <bits/stdc++.h>
using namespace std;
int C[32];
int R[32];
int B[32];
int A[1 << 16][128];
int main() {
  int n;
  scanf("%d", &n);
  int i, j, k;
  for (i = (0); i < (n); ++i) {
    char buf[4];
    int a, b;
    scanf("%s%d%d", buf, &a, &b);
    C[i] = buf[0] == 'R' ? 0 : 1;
    R[i] = a;
    B[i] = b;
  }
  int sumR = accumulate(R, R + n, 0);
  int sumB = accumulate(B, B + n, 0);
  int res = max(sumR, sumB);
  memset(A, -1, sizeof(A));
  A[0][0] = 0;
  for (i = (0); i < (1 << n); ++i)
    for (j = (0); j < (128); ++j)
      if (A[i][j] != -1) {
        int cnt[] = {0, 0};
        for (k = (0); k < (n); ++k)
          if ((i & (1 << k)) != 0) ++cnt[C[k]];
        if (cnt[0] + cnt[1] == n) res = min(res, max(sumR - j, sumB - A[i][j]));
        for (k = (0); k < (n); ++k)
          if ((i & (1 << k)) == 0) {
            int i2 = i ^ (1 << k);
            int j2 = j + min(cnt[0], R[k]);
            int v2 = A[i][j] + min(cnt[1], B[k]);
            A[i2][j2] = max(A[i2][j2], v2);
          }
      }
  res = max(res, 0);
  printf("%d\n", res + n);
  return 0;
};
