#include "bits/stdc++.h" using namespace std; const int N=1e3+3; int n,m,a[N][N],s[N][N]; int A; int w[N],h[N],pp; void sov(int x){ int i,ans=0; pp=0; h[m+1]=w[m+1]=0; for(i=1;i<=m+1;i++){ int t=0; while(pp>0&&s[x][i]<=h[pp]) t+=w[pp],ans=max(ans,t*h[pp]),pp--; h[++pp]=s[x][i]; w[pp]=t+1; } A=max(A,ans); } main(){ int i,j; char c; cin>>n>>m; for(i=1;i<=n;i++) for(j=1;j<=m;j++) cin>>c,s[i][j]=a[i][j]=(c=='F'?1:0); for(i=1;i<=n;i++) for(j=1;j<=m;j++) if(a[i][j]==1)s[i][j]+=s[i-1][j]; for(i=1;i<=n;i++) sov(i); cout<<A*3; }