from itertools import accumulate n, m = map(int, input().split()) a = [sum(list(map(int, input().split()))) for i in range(n)] dp = [[0] * n for i in range(n)] dp[0][0] = a[0] for i in range(n): for j in range(n): if not (i == 0 and j == 0): dp[i][j] = max(dp[i - 1][j], dp[i][j - 1] + a[j]) if j % 2 else max(dp[i - 1][j], dp[i][j - 1] - a[j]) print(max(dp[-1]))