#include <bits/stdc++.h>
using namespace std;
int n, r[20], b[20], mask;
int col[1 << 16][2];
unordered_map<int, int> dp[1 << 16];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int sumR = 0, sumB = 0;
  for (int i = 0; i < (int)(n); i++) {
    char c;
    cin >> c >> r[i] >> b[i];
    sumR += r[i];
    sumB += b[i];
    if (c == 'B') mask |= 1 << i;
  }
  for (int m = 1; m < (1 << n); m++) {
    int last = __builtin_ctz(m);
    int c = (mask >> last) & 1;
    int pm = m - (1 << last);
    for (int i = 0; i < (int)(2); i++) col[m][i] = col[pm][i] + (i == c);
  }
  dp[0].emplace(0, 0);
  for (int m = 0; m < (1 << n); m++) {
    for (auto &xy : dp[m]) {
      int sr = xy.first, sb = xy.second;
      for (int i = 0; i < (int)(n); i++)
        if (!(m & (1 << i))) {
          int nm = m + (1 << i);
          int nsr = sr + min(col[m][0], r[i]);
          int nsb = sb + min(col[m][1], b[i]);
          int &res = dp[nm][nsr];
          res = max(res, nsb);
        }
    }
  }
  const int INF = 1e9;
  int res = INF;
  for (auto xy : dp[(1 << n) - 1])
    res = min(res, max(sumR - xy.first, sumB - xy.second));
  res += n;
  cout << res << endl;
  return 0;
}
