#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int N;
int C[20];
int R[20], B[20];
int DP[(1 << 16) + 5][260];
int Sum[2][(1 << 16) + 5];
int sr, sb;
void precalcSum() {
  for (int j = 0; j < (1 << N); j++)
    for (int i = 0; i < N; i++) {
      if (j & (1 << i))
        Sum[0][j] = Sum[0][j ^ (1 << i)] + 1 - C[i],
        Sum[1][j] = Sum[1][j ^ (1 << i)] + C[i];
    }
}
void Read() {
  scanf("%d", &N);
  char c;
  scanf("%c", &c);
  for (int i = 0; i < N; i++) {
    scanf("\n%c", &c);
    C[i] = (c == 'R' ? 0 : 1);
    scanf("%d%d", &R[i], &B[i]);
    sr += R[i];
    sb += B[i];
  }
}
void precalcDP() {
  for (int j = 0; j < (1 << N); j++)
    for (int i = 0; i <= N * N; i++) DP[j][i] = INF;
  DP[0][0] = 0;
  for (int i = 0; i < (1 << N) - 1; i++) {
    for (int j = 0; j <= N * N; j++) {
      if (DP[i][j] == INF) continue;
      for (int k = 0; k < N; k++) {
        if ((1 << k) & i) continue;
        int val = max(0, -R[k] + Sum[0][i]);
        int val2 = max(0, B[k] - Sum[1][i]);
        DP[i ^ (1 << k)][j + min(R[k], Sum[0][i])] =
            min(DP[i ^ (1 << k)][j + min(R[k], Sum[0][i])], DP[i][j] + val2);
      }
    }
  }
  int ans = 1000000000;
  for (int r = 0; r <= min(N * N, sr); r++) {
    int realVal = sr - r;
    ans = min(ans, max(DP[(1 << N) - 1][r], realVal));
  }
  printf("%d\n", ans + N);
}
int main() {
  Read();
  precalcSum();
  precalcDP();
  return 0;
}
