/*
可二维线段树解决
对于区间更新,区间查询的问题,似乎树状数组不好做
这样硬用树状数组,似乎不太好吧
*/
// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>
using namespace std;
// typedef
typedef __int64 LL;
//
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define Z(a) (a<<1)
#define Y(a) (a>>1)
const double eps = 1e-6;
const double INFf = 1e100;
const int INFi = 1000000000;
const LL INFll = (LL)1<<62;
const double Pi = acos(-1.0);
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
if(x>y) return x;
return y;
}
template<class T> inline T TMIN(T x,T y)
{
if(x<y) return x;
return y;
}
template<class T> inline T MMAX(T x,T y,T z)
{
return TMAX(TMAX(x,y),z);
}
template<class T> inline T MMIN(T x,T y,T z)
{
return TMIN(TMIN(x,y),z);
}
template<class T> inline void SWAP(T &x,T &y)
{
T t = x;
x = y;
y = t;
}
// code begin
int N;
int Bit[110][110];
int mp[110][110];
int Nx,Ny;
inline int lowBit(int x)
{
return x&(-x);
}
void update(int x,int y,int c)
{
if(mp[x][y]==c) return;
mp[x][y] = c;
for(int i=x;i<Nx;i+=lowBit(i))
{
for(int j=y;j<Ny;j+=lowBit(j))
{
Bit[i][j] += c;
}
}
}
int getSum(int x,int y)
{
int ans = 0;
for(int i=x;i>0;i-=lowBit(i))
{
for(int j=y;j>0;j-=lowBit(j))
{
ans += Bit[i][j];
}
}
return ans;
}
int main()
{
read;
write;
char cmd[20];
int a,b,c;
scanf("%d",&N);
memset(Bit,0,sizeof(Bit));
memset(mp,-1,sizeof(mp));
Nx = Ny = 101;
while(N--)
{
scanf("%s%d%d%d",cmd,&a,&b,&c);
switch(cmd[0])
{
case 'W':
for(int i=0;i<c;i++)
{
for(int j=0;j<c;j++)
update(i+a,j+b,-1);
}
break;
case 'B':
for(int i=0;i<c;i++)
{
for(int j=0;j<c;j++)
update(i+a,j+b,1);
}
break;
case 'T':
printf("%d\n", getSum(a+c-1,b+c-1)-getSum(a+c-1,b-1)-getSum(a-1,b+c-1)+getSum(a-1,b-1) );
break;
default:
break;
}
}
return 0;
}