P4147 Yuchan Palace
Background
One day, the kittens rainbow and freda came to Yuchan Palace on Tianmen Mountain in Zhangjiajie, Western Hunan. The palace master, Blue Rabbit (Lan Tu), warmly entertained them and granted them a piece of land.
Description
This piece of land is divided into $N\times M$ cells. Each cell contains `R` or `F`. `R` means the cell is granted to rainbow, and `F` means it is granted to freda.
Now freda wants to act cute here... She wants to find a rectangular piece of land that is all `F`, with the largest possible area.
But rainbow and freda are very weak at OI, and Blue Rabbit also wants to watch freda act cute (she obviously cannot program), so they decide that if the largest area you find is $S$, each of them will give you $S$ taels of silver.
Input Format
The first line contains two integers $N$ and $M$, meaning the rectangular land has $N$ rows and $M$ columns.
The next $N$ lines each contain $M$ characters separated by spaces, each being `F` or `R`, describing the land.
Output Format
Output a single integer, the amount of silver you can get, i.e., the value of $3\times S$.
Explanation/Hint
Constraints:
- For $50\%$ of the testdata, $1 \leq N, M \leq 200$.
- For $100\%$ of the testdata, $1 \leq N, M \leq 1000$.
Translated by ChatGPT 5