#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;
int f[1010][1010];
stack<int> sta,stapos;
int maxint(int a,int b)
{
if (a>b)
return(a);
return(b);
}
int main(void)
{
freopen("jademoon.in","r",stdin);
freopen("jademoon.out","w",stdout);
int i,j,n,m,tempj,maxnum=0;
char ch;
cin>>n>>m;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
{
cin>>ch;
if (ch=='F')
f[i][j]=f[i-1][j]+1;
else
f[i][j]=0;
}
for (i=1;i<=n;i++)
f[i][m+1]=-1;
for (i=1;i<=n;i++)
{
for (j=1;j<=m+1;j++)
{
tempj=j;
if (!sta.empty())
while (sta.top()>f[i][j])
{
tempj=stapos.top();
maxnum=maxint(maxnum,((j-1)-tempj+1)*sta.top()*3);
sta.pop();
stapos.pop();
if (sta.empty())
break;
}
sta.push(f[i][j]);
stapos.push(tempj);
}
sta.pop();
stapos.pop();
}
cout<<maxnum<<endl;
return(0);
}