"Замок" – castle.
The ancient castle is shaped like a rectangle and contains at least two rooms. The castle's floor can be divided into a grid of M x N cells. Each cell is marked with either a "0" or a "1", representing empty spaces and walls, respectively.
Task:
Develop a program named "castle" that determines the area of the largest possible room that can be created by removing one internal wall, which means changing a single "1" to a "0". Note that removing external walls is not allowed.
Input Data:
The castle's layout is provided as a series of numbers, with each number representing a cell. The first line contains two integers M and N, indicating the number of rows and columns (3 ≤ M ≤ 1000, 3 ≤ N ≤ 1000). The following M lines each contain N consecutive zeros or ones (without spaces). The outermost rows and columns are the castle's external walls and consist entirely of ones.
Output
Print a single number, which is the area of the largest room that can be formed by removing one internal wall.