N,M = map(int,input().split()) A = [sum(list(map(int,input().split()))) for i in range(N)] dpMax=[0 for i in range(N)] dpMin=[0 for i in range(N)] dpMax[-1]=A[-1] dpMin[-1]=0 for i in range(N-2,-1,-1): dpMax[i]=max(dpMax[i+1],A[i]-dpMin[i+1]) dpMin[i]=min(dpMin[i],A[i]-dpMax[i+1]) print(dpMax[0])