#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define mmt(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long LL;
typedef long double LD;
char ss[3];int a[1010][1010],n,m,i,j,sum[1010],L[1010],R[1010];
int main()
{
  ios::sync_with_stdio(false);
  scanf("%d%d",&n,&m);
  FOR(i,1,n) FOR(j,1,m) {scanf("%s",ss);a[i][j]=(ss[0]=='F');}
  int ans=0;
  FOR(i,1,n)
  {
    FOR(j,1,m) if (a[i][j]==0) sum[j]=0;else sum[j]++;
    FOR(j,1,m) L[j]=0,R[j]=n+1;
    sum[0]=sum[m+1]=0;
    FOR(j,1,m)
    {
      int p=j-1;
      while (sum[p]>=sum[j]&&sum[p]) p=L[p];
      L[j]=p;
    }
    ROF(j,m,1)
    {
      int p=j+1;
      while (sum[p]>=sum[j]&&sum[p]) p=R[p];
      R[j]=p;
    }
    FOR(j,1,m)
    {
      int l=L[j]+1,r=R[j]-1;
      if ((r-l+1)*sum[j]>ans) ans=(r-l+1)*sum[j];
    }
  }
  printf("%d\n",ans*3);
  return 0;
}