#P4147. 玉蟾宫

玉蟾宫

Description

This piece of land is divided into N×MN\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 SS, each of them will give you SS taels of silver.

Input Format

The first line contains two integers NN and MM, meaning the rectangular land has NN rows and MM columns.

The next NN lines each contain MM 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×S3\times S.

5 6 
R F F F F F 
F F F F F F 
R R R F F F 
F F F F F F 
F F F F F F
45

Hint

Constraints:

  • For 50%50\% of the testdata, 1N,M2001 \leq N, M \leq 200.
  • For 100%100\% of the testdata, 1N,M10001 \leq N, M \leq 1000.

Translated by ChatGPT 5