#include <bits/stdc++.h>
using namespace std;
int dp[1 << 16][257];
int c[16], r[16], b[16];
int n;
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  char s[2];
  int sumR = 0, sumB = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", s, &r[i], &b[i]);
    if (s[0] == 'B') c[i] = 1;
    sumR += r[i];
    sumB += b[i];
  }
  dp[0][0] = 0;
  for (int st = 0; st < (1 << n); st++) {
    for (int i = 0; i <= n * n; i++) {
      if (dp[st][i] == -1) continue;
      int optR = i;
      int optB = dp[st][i];
      int R = 0, B = 0;
      for (int j = 0; j < n; j++) {
        if ((st >> j) & 1) {
          if (c[j] == 0)
            R++;
          else
            B++;
        }
      }
      for (int j = 0; j < n; j++) {
        if ((st >> j) & 1) continue;
        int addR = min(r[j], R);
        int addB = min(b[j], B);
        dp[st + (1 << j)][optR + addR] =
            max(dp[st + (1 << j)][optR + addR], optB + addB);
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i <= n * n; i++) {
    if (dp[(1 << n) - 1][i] == -1) continue;
    ans = min(ans, n + max(sumR - i, sumB - dp[(1 << n) - 1][i]));
  }
  printf("%d\n", ans);
}
