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 = {(W+H-2, H-2, H-1): 0}
def dfs(c, p, q):
    if (c, p, q) in memo:
        return memo[c, p, q]
    res = 0
    if c+1-H < p:
        res = max(res, dfs(c+1, p, q))
        if q+1 < W:
            res = max(res, dfs(c+1, p, q+1))
    if p+1 < q:
        res = max(res, dfs(c+1, p+1, q))
    if q+1 < W:
        res = max(res, dfs(c+1, p+1, q+1))
    memo[c, p, q] = res = res + A[c-p][p] + A[c-q][q]
    return res
print(dfs(1, 0, 1) + A[0][0] + A[-1][-1])