H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
if H == 1 or W == 1:
    print(sum(map(sum, A)))
    exit(0)

memo = [{} for i in range(W+H)]
def calc(c, p, q):
    yield 0
    if c+1-H < p:
        yield dfs(c+1, p, q)
        if q+1 < W:
            yield dfs(c+1, p, q+1)
    if p+1 < q:
        yield dfs(c+1, p+1, q)
    if q+1 < W:
        yield dfs(c+1, p+1, q+1)
def dfs(c, p, q):
    mc = memo[c]
    if (p, q) in mc:
        return mc[p, q]
    mc[p, q] = r = max(calc(c, p, q)) + A[c-p][p] + A[c-q][q]
    return r
print(dfs(1, 0, 1) + A[0][0] + A[-1][-1])
