Let's consider a k × k square, divided into unit squares. Please note that k ≥ 3 and is odd. We'll paint squares starting from the upper left square in the following order: first we move to the right, then down, then to the left, then up, then to the right again and so on. We finish moving in some direction in one of two cases: either we've reached the square's border or the square following after the next square is already painted. We finish painting at the moment when we cannot move in any direction and paint a square. The figure that consists of the painted squares is a spiral.

<image> The figure shows examples of spirals for k = 3, 5, 7, 9. 

You have an n × m table, each of its cells contains a number. Let's consider all possible spirals, formed by the table cells. It means that we consider all spirals of any size that don't go beyond the borders of the table. Let's find the sum of the numbers of the cells that form the spiral. You have to find the maximum of those values among all spirals.

Input

The first line contains two integers n and m (3 ≤ n, m ≤ 500) — the sizes of the table.

Each of the next n lines contains m space-separated integers: the j-th number in the i-th line aij ( - 1000 ≤ aij ≤ 1000) is the number recorded in the j-th cell of the i-th row of the table.

Output

Print a single number — the maximum sum of numbers among all spirals.

Examples

Input

6 5
0 0 0 0 0
1 1 1 1 1
0 0 0 0 1
1 1 1 0 1
1 0 0 0 1
1 1 1 1 1


Output

17

Input

3 3
1 1 1
1 0 0
1 1 1


Output

6

Input

6 6
-3 2 0 1 5 -1
4 -1 2 -3 0 1
-5 1 2 4 1 -2
0 -2 1 3 -1 2
3 1 4 -3 -2 0
-1 2 -1 3 1 2


Output

13

Note

In the first sample the spiral with maximum sum will cover all 1's of the table.

In the second sample the spiral may cover only six 1's.
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
int n, m;
long long A[505][505];
long long cnt[505][505];
long long dp[2][505][505];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> A[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long a = 0;
      if (i > 0) a = cnt[i - 1][j];
      long long b = 0;
      if (j > 0) b = cnt[i][j - 1];
      long long c = 0;
      if (i > 0 && j > 0) c = cnt[i - 1][j - 1];
      cnt[i][j] = a + b - c + A[i][j];
    }
  long long ans = -INF;
  int d = 0;
  for (int i = 0; i + 2 < n; i++)
    for (int j = 0; j + 2 < m; j++) {
      dp[d][i][j] = A[i][j] + A[i][j + 1] + A[i][j + 2] + A[i + 1][j + 2] +
                    A[i + 2][j] + A[i + 2][j + 1] + A[i + 2][j + 2];
      if (dp[d][i][j] > ans) ans = dp[d][i][j];
    }
  for (int l = 4; l < n && l < m; l += 2) {
    for (int i = 0; i + l < n; i++)
      for (int j = 0; j + l < m; j++) {
        long long a = 0;
        if (i > 0) a = cnt[i - 1][j + l];
        long long b = 0;
        if (j > 0) b = cnt[i + l][j - 1];
        long long c = 0;
        if (i > 0 && j > 0) c = cnt[i - 1][j - 1];
        dp[d ^ 1][i][j] =
            cnt[i + l][j + l] - a - b + c - dp[d][i + 1][j + 1] - A[i + 1][j];
        if (dp[d ^ 1][i][j] > ans) ans = dp[d ^ 1][i][j];
      }
    d ^= 1;
  }
  cout << ans << endl;
  return 0;
}
