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

def solve(A, W, H):
    S = {(0, 1): 0}
    for c in range(1, H-1):
        T = {}
        for p, q in S:
            v = S[p, q] + A[c-p][p] + A[c-q][q]
            T[p, q] = max(T.get((p, q), 0), v)
            if p+1 < q:
                T[p+1, q] = max(T.get((p+1, q), 0), v)
            if q+1 < W:
                T[p, q+1] = max(T.get((p, q+1), 0), v)
                T[p+1, q+1] = max(T.get((p+1, q+1), 0), v)
        S = T
    return S
B = [e[::-1] for e in A[::-1]]
S0 = solve(A, W, H)
S1 = solve(B, H, W)
print(A[0][0] + A[-1][-1] + max(S0[p, q] + S1[H-1-q, H-1-p] + A[H-1-p][p] + A[H-1-q][q] for p, q in S0))
