Aliens

National Olympiad · National Selection to IOI 2024 original (uzbek) ↗ solve ↗

Gulnoza has a garden of size \(N \times M\). If \(a[i][j]\) = "T", there is a tree in cell \((i, j)\); otherwise the cell is empty.

Gulnoza's brother Yahyo is very interested in space and wants to send a message to aliens in the shape of a rhombus. For this, he can place stones in several cells of the garden. The stones must form a rhombus when viewed from above. However, Yahyo does not want to harm the trees (Protect the trees!).

The bigger the message, the higher the probability the aliens will receive it. Create a rhombus by placing as many stones as possible!

Input

The first line contains \(N\) and \(M\) – the dimensions of Gulnoza's garden.
The next \(N\) lines each contain \(M\) characters, where "T" denotes a tree and "." denotes an empty cell.

Output

Print a single line – the maximum number of stones that can be used.

Example

For example, let \(N = 7\) and \(M = 6\). There are \(7\) trees in the field, and \(13\) stones can be placed in a rhombus shape without harming them.

input
7 6
.T...T
..T...
T....T
......
T.....
......
...T..
output
13

Constraints

Subtasks

  1. (10 points) \(N = M = 3\)
  2. (11 points) \(N, M \le 30\)
  3. (12 points) \(N, M \le 100\)
  4. (13 points) \(N, M \le 400\)
  5. (17 points) \(N, M \le 1000\) and there are at most \(10\) trees
  6. (14 points) \(N, M \le 1000\)
  7. (23 points) No additional constraints.