#include <bits/stdc++.h>
int getbit(int s, int i) { return (s >> i) & 1; }
int onbit(int s, int i) { return s | (1 << i); }
int offbit(int s, int i) { return s ^ (1 << i); }
using namespace std;
int dp[1 << (17 - 1)][150];
int n, r[17], b[17], type[17];
int main() {
  cin >> n;
  int s = 0;
  for (int i = 1; i <= n; i++) {
    char c;
    cin >> c >> r[i] >> b[i];
    type[i] = (c == 'R');
    s += r[i];
  }
  for (int mask = 0; mask <= 1 << n; mask++)
    for (int i = 0; i <= 130; i++) dp[mask][i] = (int)1e9;
  dp[0][0] = 0;
  for (int mask = 0; mask <= (1 << n) - 1; mask++)
    for (int k = 0; k <= 130; k++)
      if (dp[mask][k] < (int)1e9) {
        int R = 0, B = 0;
        for (int i = 1; i <= n; i++)
          if (getbit(mask, i - 1)) {
            R += (type[i] == 1);
            B += (type[i] == 0);
          }
        for (int i = 1; i <= n; i++)
          if (!getbit(mask, i - 1)) {
            int m = onbit(mask, i - 1);
            int ar = min(R, r[i]);
            int ab = max(0, b[i] - B);
            dp[m][k + ar] = min(dp[m][k + ar], dp[mask][k] + ab);
          }
      }
  int res = (int)1e9;
  int m = (1 << n) - 1;
  for (int i = 0; i <= 130; i++) {
    res = min(res, max(s - i, dp[m][i]));
  }
  cout << res + n;
}
