Roger, having now been bested twice in two dimensions, decides to move to three dimensions.
Roger has assembled a large block of stone, which has conveniently been subdivided into unit cubes that are either normal stones and paper. He challenges Victor to find a sub-block with a square base such that the entire sub-block contains no paper. The goal is to maximize the surface area of the components of the block perpendicular to one of the coordinate planes.
Constraints
Input Specification
The first line contains three integers,
N
for normal stone or P
for paper.
Output Specification
Output the maximum possible surface area of a valid block. In particular, the block must have dimensions
Sample Input
3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP
Sample Output
24
Comments