import numpy as np N, M = map(int, input().split()) A = [sum(map(int, input().split())) for _ in range(N)] dp1 = A[:] dp2 = [0]*N if N>1: dp1[1] = max(dp1[1],dp1[0]) dp2[1] = dp1[0]-A[1] for i in range(2,N): dp1[i] = max([dp1[i],dp1[i-1],dp2[i-1]+A[i]]) dp2[i] = max(dp1[i-1]-A[i],dp2[i-1]) print(max(dp1[-1],dp2[-1]))