#C4722. Maximum Fertile Area

    ID: 48292 Type: Default 1000ms 256MiB

Maximum Fertile Area

Maximum Fertile Area

You are given a field represented by a grid of characters consisting of F (fertile) and B (barren) cells. Your task is to find the area of the largest contiguous rectangular block within the field that contains only fertile cells.

The field is provided as m rows of characters, with each row having n characters. The rectangle must be aligned with the grid (i.e. its sides are parallel to the grid edges).

Example:

Input:
4 4
FFFF
FFBF
FFFF
FBFF

Output: 6

</p>

In the above example, the largest rectangle of fertile cells has an area of 6.

inputFormat

The first line of input contains two integers m and n — the number of rows and columns respectively. This is followed by m lines, each containing a string of length n comprised only of the characters 'F' and 'B'.

outputFormat

Output a single integer representing the area of the largest contiguous rectangular block that consists entirely of fertile cells ('F').## sample

4 4
FFFF
FFBF
FFFF
FBFF
6