H, W = gets.split.map(&:to_i)
as = []
H.times do |i|
    as[i] = gets.split.map(&:to_i)
end

dp = Array.new(H+1){Array.new(H+1, 0)}
dp[0][0] = as[0][0]

(1...(H+W-2)).each do |k|
    mini = [1, k-W+1].max
    minj = [0, k-W+1].max
    maxi = [k, H-1].min
    maxi.downto(mini) do |i|
        (i-1).downto(minj) do |j|
            dp[i][j] = [dp[i][j], dp[i-1][j], dp[i][j-1], dp[i-1][j-1]].max + as[i][k-i] + as[j][k-j]
        end
    end
end

puts dp[H-1][H-2] + as[H-1][W-1]