class Array
    def accum
        ac = Array.new(size + 1)
        ac[0] = 0
        (1..size).each do |i|
            ac[i] = ac[i-1] + self[i-1]
        end
        ac
    end
end

w, h = gets.split.map(&:to_i)
a = (1..h).map { gets.split.map(&:to_i) }
h_accum = a.map(&:accum)
v_accum = a.transpose.map(&:accum).transpose

best = (0..h).map { Array.new(w+1) }
h.downto(0) do |i|
    w.downto(0) do |j|
        if i == h && j == w
            best[i][j] = 0
        elsif i == h
            best[i][j] =   v_accum[i][j] + best[i][j+1]
        elsif j == w
            best[i][j] = - h_accum[i][j] + best[i+1][j]
        else
            candidates = [
                v_accum[i][j] + best[i][j+1],
              - h_accum[i][j] + best[i+1][j]
            ]
            best[i][j] = (i + j).even? ? candidates.max : candidates.min
        end
    end
end

p best[0][0].abs
