#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[2000][2000];
int s[2000];
int h[2000];
int l[2000];
int n,m,ans;
void work(int k){
int i,top,len,max;
memset(s,0,sizeof(s));
for (i=1;i<=m;i++)
h[i]=a[k][i];
for (i=1;i<=m;i++)
l[i]=0;
top=0;
s[top]=0;
l[top]=0;
max=0;
for (i=1;i<=m;i++)
{
if (h[i]>=s[top]){
top++;
s[top]=h[i];
l[top]=1;
}else{
len=0;
while (top>0 && s[top]>h[i]){
len+=l[top];
if (max<len*s[top])
max=len*s[top];
top--;
}
top++;
s[top]=h[i];
l[top]=len+1;
}
}
len=0;
while (top>0){
len+=l[top];
if (max<len*s[top]) max=len*s[top];
top--;
}
if (ans<max) ans=max;
}
int main(){
freopen("jademoon.in","r",stdin);
freopen("jademoon.out","w",stdout);
scanf("%d%d\n",&n,&m);
char ch;
for (int i=1;i<=n;i++){
int j;
for (j=1;j<m;j++){
scanf("%c ",&ch);
if (ch=='F')a[i][j]=a[i-1][j]+1;else a[i][j]=0;
}
scanf("%c\n",&ch);
if (ch=='F')a[i][j]=a[i-1][j]+1;else a[i][j]=0;
}
ans=0;
for (int i=1;i<=n;i++)
work(i);
printf("%d",3*ans);
return 0;
}