#include <bits/stdc++.h>
using namespace std;
struct cards {
  char C;
  int R, B;
} card[17];
int n, dp[(1 << 16)][2][(16 * 16) + 1], INF = (1 << 30), Blue, Red,
                                        basic_movement;
int DP(int mask, int blue, int how_much) {
  how_much = min(n * n, how_much);
  if (mask == (1 << n) - 1) return 0;
  int &cur = dp[mask][blue][how_much];
  if (cur != -1) return cur;
  cur = INF;
  int how_much_blue = 0, how_much_red = 0, card_red = 0, card_blue = 0;
  if (blue)
    how_much_blue = how_much;
  else
    how_much_red = how_much;
  for (int i = 0; i < 32; i++) {
    if (mask & (1 << i)) {
      if (card[i].C == 'R')
        card_red++;
      else
        card_blue++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!(mask & (1 << i))) {
      int temp_red = card[i].R;
      int temp_blue = card[i].B;
      temp_blue = max(0, temp_blue - (how_much_blue + card_blue));
      temp_red = max(0, temp_red - (how_much_red + card_red));
      int need = max(temp_blue, temp_red);
      int red_to_have = how_much_red + need - max(0, card[i].R - card_red);
      int blue_to_have = how_much_blue + need - max(0, card[i].B - card_blue);
      if (!blue_to_have) {
        cur = min(cur, DP(mask | (1 << i), 0, red_to_have) + need);
      }
      if (!red_to_have) {
        cur = min(cur, DP(mask | (1 << i), 1, blue_to_have) + need);
      }
    }
  }
  return cur;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> card[i].C >> card[i].R >> card[i].B;
    Blue += max(0, card[i].B - n);
    Red += max(0, card[i].R - n);
    card[i].R = min(card[i].R, n);
    card[i].B = min(card[i].B, n);
  }
  basic_movement = max(Blue, Red);
  if (Blue <= Red)
    cout << DP(0, 1, Red - Blue) + basic_movement + n << endl;
  else
    cout << DP(0, 0, Blue - Red) + basic_movement + n << endl;
  return 0;
}
