#include <bits/stdc++.h>
using namespace std;
struct Primal_Dual {
  const long long INF = 1LL << 59;
  struct edge {
    long long to, cap, cost, rev;
  };
  vector<vector<edge> > graph;
  vector<long long> potential, min_cost, prevv, preve;
  Primal_Dual(long long V) : graph(V) {}
  void add_edge(long long from, long long to, long long cap, long long cost) {
    graph[from].push_back((edge){to, cap, cost, (long long)graph[to].size()});
    graph[to].push_back(
        (edge){from, 0, -cost, (long long)graph[from].size() - 1});
  }
  long long min_cost_flow(long long s, long long t, long long f) {
    long long V = graph.size(), ret = 0;
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long> >,
                   greater<pair<long long, long long> > >
        que;
    potential.assign(V, 0);
    preve.assign(V, -1);
    prevv.assign(V, -1);
    while (f > 0) {
      min_cost.assign(V, INF);
      que.push(pair<long long, long long>(0, s));
      min_cost[s] = 0;
      while (!que.empty()) {
        pair<long long, long long> p = que.top();
        que.pop();
        if (min_cost[p.second] < p.first) continue;
        for (long long i = 0; i < graph[p.second].size(); i++) {
          edge &e = graph[p.second][i];
          long long nextCost = min_cost[p.second] + e.cost +
                               potential[p.second] - potential[e.to];
          if (e.cap > 0 && min_cost[e.to] > nextCost) {
            min_cost[e.to] = nextCost;
            prevv[e.to] = p.second, preve[e.to] = i;
            que.push(pair<long long, long long>(min_cost[e.to], e.to));
          }
        }
      }
      if (min_cost[t] == INF) return (114514);
      for (long long v = 0; v < V; v++) potential[v] += min_cost[v];
      long long addflow = f;
      for (long long v = t; v != s; v = prevv[v]) {
        addflow = min(addflow, graph[prevv[v]][preve[v]].cap);
      }
      f -= addflow;
      ret += addflow * potential[t];
      for (long long v = t; v != s; v = prevv[v]) {
        edge &e = graph[prevv[v]][preve[v]];
        e.cap -= addflow;
        graph[v][e.rev].cap += addflow;
      }
    }
    return ret;
  }
};
signed main() {
  long long H, W, A[200][200];
  cin >> H >> W;
  Primal_Dual flow(H * W * 2);
  auto cell = [&](long long i, long long j, bool in) {
    if (in) return (H * W + i * W + j);
    return (i * W + j);
  };
  const long long mx = 1e6;
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) {
      cin >> A[i][j];
      flow.add_edge(cell(i, j, false), cell(i, j, true), 1, mx - A[i][j]);
      flow.add_edge(cell(i, j, false), cell(i, j, true), 1, mx);
      if (i > 0) flow.add_edge(cell(i - 1, j, true), cell(i, j, false), 2, 0);
      if (j > 0) flow.add_edge(cell(i, j - 1, true), cell(i, j, false), 2, 0);
    }
  }
  cout << -flow.min_cost_flow(cell(0, 0, false), cell(H - 1, W - 1, true), 2) -
              mx * (H + W - 1) * 2
       << endl;
}
