#include <bits/stdc++.h>
using namespace std;
const int N = 16;
const int inf = int(1e9) + 7;
inline void mini(int &a, const int b) {
  if (b < a) a = b;
}
int n;
int ans[2];
int type[N];
int a[N][2];
int cnt[2];
int cnta[1 << N][2];
int f[1 << N][N * N + 1];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char c;
    scanf("\n%c", &c);
    type[i] = (c == 'B');
    cnt[type[i]]++;
    scanf("%d%d", &a[i][0], &a[i][1]);
    if (a[i][0] > n) ans[0] += a[i][0] - n, a[i][0] = n;
    if (a[i][1] > n) ans[1] += a[i][1] - n, a[i][1] = n;
  }
  for (int t = 0; t < 1 << n; t++)
    for (int i = 0; i <= n * n; i++) f[t][i] = inf;
  f[0][0] = 0;
  for (int s = 0; s < 1 << n; s++) {
    for (int k = 0; k < n; k++)
      if (s >> k & 1) {
        cnta[s][type[k]]++;
      }
    for (int i = 0; i <= n * n; i++)
      if (f[s][i] < inf) {
        int j = f[s][i];
        for (int k = 0; k < n; k++)
          if (!(s >> k & 1)) {
            int ii = i + max(a[k][0] - cnta[s][0], 0);
            int jj = j + max(a[k][1] - cnta[s][1], 0);
            mini(f[s | 1 << k][ii], jj);
          }
      }
  }
  int outcome = inf;
  for (int i = 0; i <= n * n; i++)
    if (f[(1 << n) - 1][i] < inf) {
      int j = f[(1 << n) - 1][i];
      mini(outcome, max(ans[0] + i, ans[1] + j));
    }
  printf("%d\n", outcome + n);
}
