#include <bits/stdc++.h>
using namespace std;
const int N = 16;
int a[N], b[N], n, suma, sumb, dp[1 << N][N * N + 1], col;
inline void upd(int& x, const int& y) { x < y ? x = y : 0; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char x;
    cin >> x >> a[i] >> b[i];
    col |= (x == 'R') << i;
    suma += a[i];
    sumb += b[i];
  }
  memset(dp, 0x88, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int A = __builtin_popcount(i & col), B = __builtin_popcount(i) - A;
    for (int j = 0; j <= n * n; ++j)
      if (dp[i][j] >= 0)
        for (int k = 0; k < n; ++k)
          if (!(i >> k & 1))
            upd(dp[i | (1 << k)][j + min(A, a[k])], dp[i][j] + min(B, b[k]));
  }
  int ans = INT_MAX;
  for (int i = 0; i <= n * n; ++i)
    if (dp[(1 << n) - 1][i] >= 0)
      ans = min(ans, max(suma - i, sumb - dp[(1 << n) - 1][i]));
  cout << (n + ans) << '\n';
  return 0;
}
