N, M = map(int, input().split()) dp1 = 0 A = [sum(map(int, input().split())) for i in range(N)] dp2 = A[0] for i in A: dp1, dp2 = max(dp1, dp2 - i), max(dp2, dp1 + i) print(max(dp1, dp2))