#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=2010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int n,a[Maxn<<1],c[Maxn<<1],s[2][Maxn<<1][Maxn],pos[2][Maxn];LL f[Maxn][Maxn];
char str[3];
int main()
{
	n=read();
	for(int i=1;i<=(n<<1);i++)
	{
		scanf("%s",str);
		a[i]=read();
		if(str[0]=='W')c[i]=0;else c[i]=1;
		pos[c[i]][a[i]]=i;
		for(int o=0;o<2;o++)
		for(int j=1;j<=n;j++)
		s[o][i][j]=s[o][i-1][j];
		for(int j=a[i];j<=n;j++)
		s[c[i]][i][j]++;
	}
	f[0][0]=0;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	{
		if(!i&&!j)continue;
		f[i][j]=1LL<<60;
		int p;
		if(i)
		{
			p=pos[0][i];
			f[i][j]=min(f[i][j],f[i-1][j]+((LL)i+j-1-s[0][p][i-1]-s[1][p][j]));
		}
		if(j)
		{
			p=pos[1][j];
			f[i][j]=min(f[i][j],f[i][j-1]+((LL)i+j-1-s[0][p][i]-s[1][p][j-1]));
		}
//		printf("%d %d %lld\n",i,j,f[i][j]);
	}
	printf("%lld",f[n][n]);
}