#include <iostream>
int p[555][555], a[555][555], n, m, k, t, r1, r2, X, Y, i, j, L, R, q = -1e9;
char c;
int main() {
std::cin >> n >> m >> k;
for (; i < k; ++i) {
std::cin >> Y >> X >> c;
a[Y][X] = (c == 'K' ? -10 : 1);
t += a[Y][X];
}
for (i = 1; i <= n; ++i)
for (j = 1; j <= m; ++j) p[i][j] = p[i][j-1]+a[i][j];
for (i = 1; i <= n; ++i) {
for (j = 1; j <= m; ++j) {
r1 = r2 = a[i][j];
q = std::max(q,std::max(t-r1,t-r2));
Y = i, X = i, L = j, R = j;
while (true) {
++Y; --X;
R += (Y&1);
L -= (!(Y&1));
r1 += (p[Y][R]-p[Y][L-1])*(Y > 0 && Y <= n && L > 0 && R <= m);
r2 += (p[X][R]-p[X][L-1])*(X > 0 && X <= n && L > 0 && R <= m);
if (!(Y > 0 && Y <= n &&) !(L > 0 && R <= m) && !(X > 0 && X <= n))
break;
q = std::max(q,std::max(t-r1,t-r2));
}
q = std::max(q,std::max(t-r1,t-r2));
}
}
std::cout << q;
}