#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b, long long M) {
  long long t = 1;
  for (a %= M; b; b >>= 1) {
    if (b & 1) t = t * a % M;
    a = a * a % M;
  }
  return t;
}
const int N = 16;
int f[1 << N][288][2];
int c[N], r[N], b[N], n, rem = 1e9;
int Mn(int& a, int b) { return a > b ? a = b, 1 : 0; }
int main() {
  int cr = 0, cb = 0;
  cin >> n;
  for (int i = 0; i <= int(n - 1); i++) {
    char s[5];
    scanf("%s%d%d", s, &r[i], &b[i]);
    if (s[0] == 'R')
      c[i] = 0;
    else
      c[i] = 1;
    if (r[i] > n) cr += r[i] - n, r[i] = n;
    if (b[i] > n) cb += b[i] - n, b[i] = n;
  }
  memset(f, 0x3f, sizeof(f));
  if (cr < cb)
    f[0][min(cb - cr, n * n)][0] = 0;
  else
    f[0][min(cr - cb, n * n)][1] = 0;
  for (int i = 0; i <= int((1 << n) - 1); i++) {
    int R = 0, B = 0;
    for (int k = i; k; k -= k & -k) {
      int l = __builtin_ctz(k & -k);
      if (c[l] == 0)
        R++;
      else
        B++;
    }
    for (int j = 0; j <= int(n * n); j++)
      if (f[i][j][0] < 1e9 || f[i][j][1] < 1e9) {
        for (int k = ~i & (1 << n) - 1; k; k -= k & -k) {
          int l = __builtin_ctz(k & -k);
          int nr = max(r[l] - R, 0);
          int nb = max(b[l] - B, 0);
          int x = max(nr - j, nb);
          if (x > nr - j)
            Mn(f[i ^ 1 << l][min(n * n, x - nr + j)][0], f[i][j][0] + x);
          else
            Mn(f[i ^ 1 << l][x - nb][1], f[i][j][0] + x);
          x = max(nr, nb - j);
          if (x > nr)
            Mn(f[i ^ 1 << l][x - nr][0], f[i][j][1] + x);
          else
            Mn(f[i ^ 1 << l][min(n * n, x - nb + j)][1], f[i][j][1] + x);
        }
        if (i == (1 << n) - 1) Mn(rem, min(f[i][j][0], f[i][j][1]));
      }
  }
  cout << max(cr, cb) + rem + n;
}
