a, b = tuple([int(i) for i in input().split()])
x = []
for i in range(a):
    x.append([int(i) for i in input().split()])

s = sum(sum(x, []))
if a % 2 == 0 or b % 2 == 0:
    x[0][0] = float("inf")
    s -= min(min(x, key=min))
print(s)

'''axes = [(0, 1), (1, 0), (-1, 0), (0, -1)]
highest = 0
start = (0, 0)
finish = (b-1, a-1)
options = [[start, [start], x[start[1]][start[0]]]]

while options:
    newOptions = []
    for option in options:
        for axe in axes:
            p, q = option[0][0] + axe[0], option[0][1] + axe[1]
            if (p, q) == finish:
                highest = max(highest, option[2] + x[q][p])
            elif 0 <= p < b and 0 <= q < a and (p, q) not in option[1]:
                newOptions.append([(p, q), option[1].copy() + [(p, q)], option[2] + x[q][p]])
    options = newOptions.copy()
'''

