#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> R, B;
vector<bool> isred;
int DP[2][257][1 << 16];
int f(bool red, int extra, int bs) {
  if (bs == (1 << N) - 1) return 0;
  if (DP[red][extra][bs] != -1) return DP[red][extra][bs];
  int numR = 0, numB = 0;
  for (int i = 0; i < N; ++i)
    if (bs & (1 << i)) {
      if (isred[i]) {
        ++numR;
      } else {
        ++numB;
      }
    }
  int extraR = red * extra, extraB = (!red) * extra;
  int ans = 1e9;
  for (int i = 0; i < N; ++i)
    if (!(bs & (1 << i))) {
      int needR = max(max(R[i] - numR, 0) - extraR, 0);
      int _extraR = max(extraR - max(R[i] - numR, 0), 0);
      int needB = max(max(B[i] - numB, 0) - extraB, 0);
      int _extraB = max(extraB - max(B[i] - numB, 0), 0);
      int cost = max(needR, needB) + 1;
      if (needR > needB) {
        ans = min(
            ans,
            f(0, min(N * N, (needR - needB) + _extraB), bs | (1 << i)) + cost);
      } else if (needB > needR) {
        ans = min(
            ans,
            f(1, min(N * N, (needB - needR) + _extraR), bs | (1 << i)) + cost);
      } else {
        ans = min(ans,
                  f(_extraR, min(N * N, max(_extraR, _extraB)), bs | (1 << i)) +
                      cost);
      }
    }
  return DP[red][extra][bs] = ans;
}
int solve_fast() {
  int overR = 0, overB = 0;
  for (int i = 0; i < N; ++i) {
    if (R[i] > N) {
      overR += R[i] - N;
      R[i] = N;
    }
    if (B[i] > N) {
      overB += B[i] - N;
      B[i] = N;
    }
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 257; ++j) {
      for (int k = 0; k < (1 << 16); ++k) {
        DP[i][j][k] = -1;
      }
    }
  }
  return f(overB > overR, min(N * N, abs(overR - overB)), 0) +
         max(overR, overB);
}
int solve_slow() {
  vector<int> perm(N);
  for (int i = 0; i < N; ++i) {
    perm[i] = i;
  }
  int ans = 1e9;
  do {
    int cost = N;
    int numB = 0, numR = 0;
    int resB = 0, resR = 0;
    for (int i = 0; i < N; ++i) {
      int needR = max(max(R[perm[i]] - numR, 0) - resR, 0);
      resR = max(resR - max(R[perm[i]] - numR, 0), 0);
      int needB = max(max(B[perm[i]] - numB, 0) - resB, 0);
      resB = max(resB - max(B[perm[i]] - numB, 0), 0);
      if (needR > needB)
        resB += needR - needB;
      else if (needB > needR)
        resR += needB - needR;
      cost += max(needB, needR);
      if (isred[perm[i]])
        ++numR;
      else
        ++numB;
    }
    ans = min(ans, cost);
  } while (next_permutation(perm.begin(), perm.end()));
  return ans;
}
void test() {
  int CASES = 1000;
  N = 6;
  R = B = vector<int>(N);
  isred.assign(N, 0);
  int max_cost = 1e7;
  default_random_engine re;
  for (int tc = 0; tc < CASES; ++tc) {
    cout << N << endl;
    for (int i = 0; i < N; ++i) {
      isred[i] = re() % 2;
      R[i] = re() % max_cost;
      B[i] = re() % max_cost;
      cout << (isred[i] ? 'R' : 'B') << " " << R[i] << " " << B[i] << endl;
    }
    int slow = solve_slow(), fast = solve_fast();
    cout << "ANS: " << slow << " " << fast << endl;
    assert(slow == fast);
  }
}
int main() {
  cin >> N;
  R = B = vector<int>(N);
  isred.resize(N);
  for (int i = 0; i < N; ++i) {
    char c;
    cin >> c;
    isred[i] = c == 'R';
    cin >> R[i] >> B[i];
  }
  cout << solve_fast() << endl;
}
