#include <bits/stdc++.h>
using namespace std;

int N;
#define MAX_N 2000
int C[2 * MAX_N], A[2 * MAX_N];
int P[2][MAX_N];
int F[2][MAX_N + 1][2 * MAX_N];
int D[MAX_N + 1][MAX_N + 1];

int main() {
  cin >> N;
  for(int i = 0; i < 2 * N; ++i) {
    char c; int a; cin >> c >> a; --a;
    C[i] = c == 'W'; A[i] = a; P[C[i]][A[i]] = i;
  }
  for(int i = 2 * N - 2; i >= 0; --i) {
    for(int c = 0; c < 2; ++c) for(int a = 0; a <= N; ++a) {
      F[c][a][i] = F[c][a][i + 1] + (c == C[i + 1] && a > A[i + 1]);
    }
  }
  for(int i = 0; i <= N; ++i) for(int j = 0; j <= N; ++j) {
    if(i == 0 && j == 0) continue;
    D[i][j] = 1e9;
    if(i > 0) D[i][j] = min(D[i][j],
      D[i - 1][j] + F[0][i - 1][P[0][i - 1]] + F[1][j][P[0][i - 1]]);
    if(j > 0) D[i][j] = min(D[i][j],
      D[i][j - 1] + F[1][j - 1][P[1][j - 1]] + F[0][i][P[1][j - 1]]);
  }
  cout << D[N][N] << endl;
  return 0;
}
