#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define rep(i,x,y) for(int i=x;i<=y;i++)
const int N=1000+10;
int t,m,n;
int heights[N][N],vis[N];
vector<int> vec;
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
memset(heights,0,sizeof(heights));
rep(i,1,n)
rep(j,1,m)
{
char ch;
cin>>ch;
if(ch=='F')
heights[i][j]=heights[i-1][j]+1;
}
rep(i,1,n)
heights[i][m+1]=-1;
int res=0;
stack<int> st;
rep(i,1,n)
{
rep(j,1,m+1)
{
while(st.size()&&heights[i][st.top()]>heights[i][j])
{
int val=st.top();
int height=heights[i][val];
int width;
st.pop();
width=j-val;
res=max(res,height*width);
//cout<<width<<" "<<height<<endl;
}
st.push(j);
}
while(st.size()) st.pop();
}
cout<<res*3<<endl;
return 0;
}
WA在第7、8、9三个点了,不知道哪里出错了,求各位大佬指点。