#atcoder problem solving


#problem name --> お土産購入計画2

#tle -solution 10**8 order
def main():
    H,W = map(int,input().split())
    data = [[0]+list(map(int,input().split())) for i in range(H)]
    for i in range(H):
        for j in range(1,W+1):
            data[i][j] += data[i][j-1]
            
    #dp[height][left][right] assert 1<=height<=H, 1<=left<right<=W
    
    dp = [[[0]*(W+1) for j in range(W+1)]for i in range(H+1)]   
    H_dp = [[[0]*(W+1) for j in range(W+1)] for i in range(H+1)]
    W_dp = [[[0]*(W+1) for j in range(W+1)] for   i in range(H+1)]


    #initializaton : height is 1.

    for i in range(1,W+1):
            for j in range(i+1,W+1):
                dp[1][i][j] =data[0][j]

    for height in range(2,H+1):
        for i in range(1,W+1):
            for j in range(i+1,W+1):
                dp[height][i][j] = max(max(dp[height-1][i][k] +data[height-1][j]-data[height-1][k-1] for k in range(i+1,j+1))+data[height-1][i]-data[height-1][i-1],dp[height][i][j])
                dp[height][i][j] = max(max(dp[height-1][l][j]+data[height-1][i]-data[height-1][l-1] for l in range(1,i+1))+data[height-1][j]-data[height-1][j-1],dp[height][i][j])
    

    ans = dp[H][W-1][W]
    
    print(ans)
    return


if __name__ == "__main__":
    main()
