#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
double PI = 4 * atan(1);
map<int, int> rec[1 << 16];
pair<int, int> rb[1 << 16];
pair<int, pair<int, int> > cards[16];
int n;
void dp(int cur) {
  if (rec[cur].size()) return;
  for (int i = 0; i < n; i++)
    if (cur & (1 << i)) {
      int temp = cur ^ (1 << i);
      dp(temp);
      rb[cur] = rb[temp];
      if (cards[i].first == 0)
        rb[cur].first++;
      else
        rb[cur].second++;
      int c1 = max(0, cards[i].second.first - rb[temp].first);
      int c2 = max(0, cards[i].second.second - rb[temp].second);
      for (auto a : rec[temp]) {
        if (rec[cur].find(a.first + c1) == rec[cur].end())
          rec[cur][a.first + c1] = a.second + c2;
        else
          rec[cur][a.first + c1] = min(rec[cur][a.first + c1], a.second + c2);
      }
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (c == 'B') cards[i].first = 1;
    cin >> cards[i].second.first >> cards[i].second.second;
  }
  rec[0][0] = 0;
  dp((1 << n) - 1);
  int ans = MOD;
  for (pair<int, int> x : rec[(1 << n) - 1]) {
    ans = min(ans, max(x.first, x.second));
  }
  cout << (ans + n);
}
