#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>

const int INF = 0x3f3f3f3f;
const int kN = 2000 + 5;
int n;
int pos[2][kN];
int inv[2][kN][kN];
int dp[kN][kN];

inline void update(int &a, int b) {
  if (a > b) a = b;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n + n; ++ i) {
    char s[2];
    int a;
    scanf("%s%d", s, &a);
    pos[s[0] == 'W'][a] = i;
  }
  for (int c = 0; c < 2; ++ c) {
    for (int i = 1; i <= n; ++ i) {
      for (int j = 1; j <= n; ++ j) {
        inv[c][i][j] = inv[c][i][j - 1] + (pos[c][i] < pos[c ^ 1][j]);
      }
    }
  }
  memset(dp, INF, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i <= n; ++ i) {
    for (int j = 0; j <= n; ++ j) {
      if (i < n)
        update(dp[i + 1][j], dp[i][j] + inv[0][i + 1][j]);
      if (j < n)
        update(dp[i][j + 1], dp[i][j] + inv[1][j + 1][i]);
    }
  }
  int result = dp[n][n];
  for (int c = 0; c < 2; ++ c) {
    for (int i = 1; i <= n; ++ i) {
      for (int j = 1; j < i; ++ j)
        result += pos[c][i] < pos[c][j];
    }
  }
  printf("%d\n", result);
}
