#include <bits/stdc++.h>
using namespace std;
map<pair<pair<int, int>, pair<int, int> >, int> cur;
map<pair<pair<int, int>, pair<int, int> >, int> nnext;
int H, W;
int a[205][205];
int main() {
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  cur[make_pair(make_pair(0, 0), make_pair(0, 0))] = 0;
  while (true) {
    for (auto c : cur) {
      int i = c.first.first.first;
      int j = c.first.first.second;
      int k = c.first.second.first;
      int l = c.first.second.second;
      int ori = c.second;
      if (i != H - 1) {
        if (k != H - 1) {
          if (i + 1 != k + 1 || j != l) {
            nnext[make_pair(make_pair(i + 1, j), make_pair(k + 1, l))] =
                max(nnext[make_pair(make_pair(i + 1, j), make_pair(k + 1, l))],
                    ori + a[i][j] + a[k][l]);
          }
          if (i + 1 == H - 1 && k + 1 == W - 1) {
            nnext[make_pair(make_pair(i + 1, j), make_pair(k + 1, l))] =
                max(nnext[make_pair(make_pair(i + 1, j), make_pair(k + 1, l))],
                    ori + a[i][j] + a[k][l]);
          }
        }
        if (l != W - 1) {
          if (i + 1 != k || j != l + 1) {
            nnext[make_pair(make_pair(i + 1, j), make_pair(k, l + 1))] =
                max(nnext[make_pair(make_pair(i + 1, j), make_pair(k, l + 1))],
                    ori + a[i][j] + a[k][l]);
          }
          if (i + 1 == H - 1 && j == W - 1) {
            nnext[make_pair(make_pair(i + 1, j), make_pair(k, l + 1))] =
                max(nnext[make_pair(make_pair(i + 1, j), make_pair(k, l + 1))],
                    ori + a[i][j] + a[k][l]);
          }
        }
      }
      if (j != W - 1) {
        if (k != H - 1) {
          if (i != k + 1 || j + 1 != l) {
            nnext[make_pair(make_pair(i, j + 1), make_pair(k + 1, l))] =
                max(nnext[make_pair(make_pair(i, j + 1), make_pair(k + 1, l))],
                    ori + a[i][j] + a[k][l]);
          }
          if (i == H - 1 && j + 1 == W - 1) {
            nnext[make_pair(make_pair(i, j + 1), make_pair(k + 1, l))] =
                max(nnext[make_pair(make_pair(i, j + 1), make_pair(k + 1, l))],
                    ori + a[i][j] + a[k][l]);
          }
        }
        if (l != W - 1) {
          if (i != k + 1 || j != l + 1) {
            nnext[make_pair(make_pair(i, j + 1), make_pair(k, l + 1))] =
                max(nnext[make_pair(make_pair(i, j + 1), make_pair(k, l + 1))],
                    ori + a[i][j] + a[k][l]);
          }
          if (i == H - 1 && j == W - 1) {
            nnext[make_pair(make_pair(i, j + 1), make_pair(k, l + 1))] =
                max(nnext[make_pair(make_pair(i, j + 1), make_pair(k, l + 1))],
                    ori + a[i][j] + a[k][l]);
          }
        }
      }
    }
    if (nnext.size() == 1) {
      break;
    }
    swap(cur, nnext);
    nnext.clear();
  }
  for (auto n : nnext) {
    cout << n.second + a[H - 1][W - 1] - a[0][0] << endl;
  }
  return 0;
}
