#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int INF=0x7fffffff;
const int maxn=2005;
int n,a[maxn<<1],t,dp[maxn][maxn],f[maxn<<1][maxn<<1];
char ch[10];

int cal(int x,int b,int w) 
{
	return f[x][b]-f[x-1][b]+f[x][w]-f[x][n]-f[x-1][w]+f[x-1][n];
}

int main() 
{
	
	scanf("%d",&n);
	for(int i=1; i<=n<<1; i++) 
	{
		scanf("%s",&ch);
		scanf("%d",&a[i]);
		if (ch[0]=='W') a[i]+=n;
		for (int j=1; j<i; j++)
			f[a[j]][a[i]]=1;
	}
	
	for (int i=1; i<=n<<1; i++)
		for (int j=1; j<=n<<1; j++)
			f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
			
	memset(dp,0x7f,sizeof(dp));
	dp[0][0]=0;
	for (int i=0; i<=n; i++) 
	{
		for (int j=0; j<=n; j++) 
		{
			if(i==0 && j==0) continue;
			dp[i][j]=min(i?dp[i-1][j]+cal(i, i, j+n):INF,j?dp[i][j-1]+cal(j+n, i, j+n):INF);
		}
	}
	printf("%d\n", dp[n][n]);
	return 0;
}