#include
#include
using namespace std;
int main() {
// your code goes here
int n,q;
cin>>n>>q;
long long int max=0;
int v[n][n];
for(int i=0;i<q;i++)
{
string s;
int a,b;
cin>>s>>a>>b;
if(s=="ColAdd")
{
for(int j=0;j<n;j++)
{
v[a-1][j]=v[a-1][j]+b;
if(v[a-1][j]>=max) max=v[a-1][j];
}
}
else
{
for(int j=0;j<(n);j++)
{
v[j][a-1]=v[j][a-1]+b;
if(v[j][a-1]>=max) max=v[j][a-1];
}
}
}
cout<<max<<endl;
return 0;
}