#include <bits/stdc++.h>
using namespace std;
const int N = 17;
const int M = 1 << N;
const int CHAR_SIZE = 2;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
char s[N][3];
int r[N], b[N];
long long dp[M][150];
long long totr, totb;
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", s[i], &r[i], &b[i]);
    totr += r[i];
    totb += b[i];
  }
  memset(dp, -INF, sizeof(dp));
  dp[0][0] = 0;
  for (int st = 1; st < (1 << n); st++)
    for (int i = 0; i < n; i++)
      if ((st >> i) & 1) {
        int ps = st ^ (1 << i);
        int nr = 0, nb = 0;
        for (int k = 0; k < n; k++)
          if (ps & (1 << k)) {
            nr += (s[k][0] == 'R');
            nb += (s[k][0] == 'B');
          }
        int sr = min(r[i], nr);
        int sb = min(b[i], nb);
        for (int j = sr; j < 150; j++) {
          dp[st][j] = max(dp[st][j], dp[ps][j - sr] + sb);
        }
      }
  long long ans = INF;
  int p = (1 << n) - 1;
  for (int i = 0; i < 150; i++) ans = min(ans, max(totr - i, totb - dp[p][i]));
  cout << ans + n;
  return 0;
}
