#pragma GCC optimize("O2")
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char buf[2100000], *ptr = buf - 1;
inline int readint(){
int n = 0;
char ch = *++ptr;
while(ch < ‘0‘ || ch > ‘9‘) ch = *++ptr;
while(ch <= ‘9‘ && ch >= ‘0‘){
n = (n << 1) + (n << 3) + (ch ^ 48);
ch = *++ptr;
}
return n;
}
const int maxn = 1000 + 10;
int n, m, ans = 0;
int top[maxn] = {0};
int s[maxn], l[maxn], t = 0;
inline void work(){
int len;
for(int i = 1; i <= m; i++){
if(!t || top[i] > top[s[t]]){
s[++t] = i;
l[t] = 1;
}
else{
len = 0;
while(t && top[s[t]] >= top[i]){
len += l[t];
ans = max(ans, len * top[s[t]]);
t--;
}
s[++t] = i;
l[t] = len + 1;
}
}
len = 0;
while(t){
len += l[t];
ans = max(ans, len * top[s[t]]);
t--;
}
}
int main(){
fread(buf, sizeof(char), sizeof(buf), stdin);
n = readint();
m = readint();
char ch;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
ch = *++ptr;
while(ch != ‘F‘ && ch != ‘R‘) ch = *++ptr;
if(ch == ‘F‘) top[j]++;
else top[j] = 0;
}
work();
}
printf("%d\n", ans * 3);
return 0;
}