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