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 dfs(c, p, q):
    mc = memo[c]
    if (p, q) in mc:
        return mc[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))
    mc[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])